Обновить ansible/npm-setup.yml
This commit is contained in:
+47
-28
@@ -2,10 +2,6 @@
|
||||
- name: Validate input and add host dynamically
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
# Пытаемся определить метод аутентификации
|
||||
auth_method: "{{ 'key' if ssh_key_path is defined else 'password' }}"
|
||||
|
||||
tasks:
|
||||
- name: Check if vm_ip is provided
|
||||
fail:
|
||||
@@ -60,48 +56,65 @@
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
# ... остальные задачи как выше ...
|
||||
- name: Test connection
|
||||
ping:
|
||||
|
||||
- name: Update apt cache
|
||||
- name: Update apt cache and install prerequisites
|
||||
apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Install Docker prerequisites
|
||||
apt:
|
||||
name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg', 'lsb-release']
|
||||
state: present
|
||||
|
||||
- name: Add Docker GPG key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/debian/gpg
|
||||
state: present
|
||||
- name: Add Docker GPG key (modern method)
|
||||
shell: |
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||||
args:
|
||||
creates: /usr/share/keyrings/docker-archive-keyring.gpg
|
||||
|
||||
- name: Add Docker repository
|
||||
apt_repository:
|
||||
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
shell: |
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
args:
|
||||
creates: /etc/apt/sources.list.d/docker.list
|
||||
|
||||
- name: Install Docker
|
||||
- name: Update apt cache with Docker repository
|
||||
apt:
|
||||
name: ['docker-ce', 'docker-ce-cli', 'containerd.io', 'docker-compose-plugin']
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Start Docker
|
||||
- name: Install Docker and Docker Compose Plugin
|
||||
apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose-plugin
|
||||
state: present
|
||||
|
||||
- name: Ensure Docker service is running and enabled
|
||||
systemd:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: Setup Nginx Proxy Manager
|
||||
- name: Add user to docker group
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
groups: docker
|
||||
append: yes
|
||||
when: ansible_user != 'root'
|
||||
|
||||
- name: Create directory for Nginx Proxy Manager
|
||||
file:
|
||||
path: /opt/npm
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Deploy NPM compose file
|
||||
- name: Create docker-compose.yml for NPM
|
||||
copy:
|
||||
dest: /opt/npm/docker-compose.yml
|
||||
content: |
|
||||
@@ -118,17 +131,23 @@
|
||||
- ./data:/data
|
||||
- ./letsencrypt:/etc/letsencrypt
|
||||
|
||||
- name: Start NPM
|
||||
- name: Run Nginx Proxy Manager via Docker Compose
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: /opt/npm
|
||||
state: present
|
||||
|
||||
- name: Success message
|
||||
- name: Display access information
|
||||
debug:
|
||||
msg: |
|
||||
========================================
|
||||
✅ Docker and Nginx Proxy Manager installed!
|
||||
|
||||
Access NPM Admin: http://{{ vm_ip }}:81
|
||||
Default login: admin@example.com / changeme
|
||||
Access URLs:
|
||||
- Admin Panel: http://{{ vm_ip }}:81
|
||||
- HTTP Proxy: http://{{ vm_ip }}
|
||||
- HTTPS Proxy: https://{{ vm_ip }}
|
||||
|
||||
Default Admin Credentials:
|
||||
- Email: admin@example.com
|
||||
- Password: changeme
|
||||
========================================
|
||||
Reference in New Issue
Block a user