--- # 1. Динамическое добавление машины в инвентарь - name: Add dynamically provisioned host hosts: localhost gather_facts: no tasks: - name: Add new VM IP to inventory add_host: name: "{{ vm_ip }}" groups: npm_servers ansible_user: ogrechko # Замените на логин вашего шаблона ansible_ssh_common_args: '-o StrictHostKeyChecking=no' # 2. Основная настройка NPM - name: Setup Minimal Linux with Docker and Nginx Proxy Manager hosts: npm_servers become: yes gather_facts: yes tasks: - name: Update apt cache and install prerequisites apt: name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg', 'lsb-release'] state: present update_cache: yes - name: Add Docker GPG apt Key apt_key: url: https://download.docker.com/linux/debian/gpg state: present - name: Add Docker Repository apt_repository: repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable" state: present - name: Install Docker and Docker Compose Plugin apt: name: ['docker-ce', 'docker-ce-cli', 'containerd.io', 'docker-compose-plugin'] state: present update_cache: yes - name: Ensure Docker service is running and enabled systemd: name: docker state: started enabled: yes - name: Create directory for Nginx Proxy Manager file: path: /opt/npm state: directory mode: '0755' - name: Create docker-compose.yml for NPM copy: dest: /opt/npm/docker-compose.yml content: | version: '3.8' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' - '81:81' - '443:443' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt - name: Run Nginx Proxy Manager via Docker Compose community.docker.docker_compose_v2: project_src: /opt/npm state: present