--- # Deploy Traefik Configuration Files - name: Check if local Traefik config directory exists ansible.builtin.stat: path: "{{ traefik_local_config_path }}" register: local_traefik_exists delegate_to: localhost run_once: true - name: Fail if local Traefik config directory does not exist ansible.builtin.fail: msg: "Local Traefik config directory not found at {{ traefik_local_config_path }}" when: not local_traefik_exists.stat.exists delegate_to: localhost run_once: true - name: Check if remote Traefik stack directory exists ansible.builtin.stat: path: "{{ traefik_stack_path }}" register: traefik_stack_exists - name: Fail if remote Traefik stack directory does not exist ansible.builtin.fail: msg: "Remote Traefik stack directory not found at {{ traefik_stack_path }}" when: not traefik_stack_exists.stat.exists - name: Deploy docker-compose.yml ansible.builtin.copy: src: "{{ traefik_local_config_path }}/docker-compose.yml" dest: "{{ traefik_stack_path }}/docker-compose.yml" mode: '0644' owner: "{{ ansible_user }}" group: "{{ ansible_user }}" register: docker_compose_deployed - name: Deploy traefik.yml ansible.builtin.copy: src: "{{ traefik_local_config_path }}/traefik.yml" dest: "{{ traefik_stack_path }}/traefik.yml" mode: '0644' owner: "{{ ansible_user }}" group: "{{ ansible_user }}" register: traefik_yml_deployed - name: Display deployment status ansible.builtin.debug: msg: | ======================================== Traefik Configuration Deployment ======================================== docker-compose.yml: {{ '✅ DEPLOYED' if docker_compose_deployed.changed else 'ℹ️ No changes' }} traefik.yml: {{ '✅ DEPLOYED' if traefik_yml_deployed.changed else 'ℹ️ No changes' }} ======================================== {% if docker_compose_deployed.changed or traefik_yml_deployed.changed %} ✅ Configuration files deployed successfully! {% if traefik_auto_restart | default(true) | bool %} Next: Traefik will be restarted automatically to apply changes. {% else %} Next step: Restart Traefik to apply changes: ansible-playbook -i inventory/production.yml playbooks/restart-traefik.yml --vault-password-file secrets/.vault_pass {% endif %} {% else %} ℹ️ Configuration files are already up to date. {% endif %} when: traefik_show_status | default(true) | bool - name: Restart Traefik after config deployment include_tasks: restart.yml when: - (docker_compose_deployed.changed or traefik_yml_deployed.changed) - traefik_auto_restart | default(true) | bool vars: traefik_restart_action: restart traefik_show_status: false