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