diff --git a/deployment/ansible/playbooks/deploy-traefik-config.yml b/deployment/ansible/playbooks/deploy-traefik-config.yml new file mode 100644 index 00000000..9562fb40 --- /dev/null +++ b/deployment/ansible/playbooks/deploy-traefik-config.yml @@ -0,0 +1,72 @@ +--- +- name: Deploy Traefik Configuration Files + hosts: production + gather_facts: yes + become: no + + vars: + traefik_stack_path: "{{ stacks_base_path | default('/home/deploy/deployment/stacks') }}/traefik" + local_traefik_path: "{{ playbook_dir }}/../../stacks/traefik" + + tasks: + - name: Check if local Traefik config directory exists + stat: + path: "{{ local_traefik_path }}" + register: local_traefik_exists + delegate_to: localhost + run_once: true + + - name: Fail if local Traefik config directory does not exist + fail: + msg: "Local Traefik config directory not found at {{ local_traefik_path }}" + when: not local_traefik_exists.stat.exists + delegate_to: localhost + run_once: true + + - name: Check if remote Traefik stack directory exists + stat: + path: "{{ traefik_stack_path }}" + register: traefik_stack_exists + + - name: Fail if remote Traefik stack directory does not exist + fail: + msg: "Remote Traefik stack directory not found at {{ traefik_stack_path }}" + when: not traefik_stack_exists.stat.exists + + - name: Deploy docker-compose.yml + copy: + src: "{{ local_traefik_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 + copy: + src: "{{ local_traefik_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 + 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! + + Next step: Restart Traefik to apply changes: + ansible-playbook -i inventory/production.yml playbooks/restart-traefik.yml --vault-password-file secrets/.vault_pass + {% else %} + ℹ️ Configuration files are already up to date. + {% endif %} +