1
0
Fork 0
myserver-configuration/roles/traefik/tasks/base.yml

41 lines
1 KiB
YAML
Raw Normal View History

2023-05-03 21:30:58 +02:00
---
- name: Copy traefik conf
ansible.builtin.copy:
2023-05-20 15:53:20 +02:00
backup: true
src: .
dest: traefik/
register: traefik_copy_files_results
- name: Copy template conf
ansible.builtin.template:
backup: true
src: "{{ item.src }}"
dest: "traefik/{{ item.dest }}"
loop:
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
- { src: 'config/traefik.yml.j2', dest: 'config/traefik.yml' }
register: traefik_copy_templates_results
2023-05-03 22:35:19 +02:00
- name: Create proxy network
community.docker.docker_network:
2023-05-20 15:53:20 +02:00
name: proxy
state: present
2023-05-03 22:35:19 +02:00
become: true
2023-05-04 23:03:39 +02:00
- name: Force update and restart container
community.docker.docker_compose:
2023-05-20 15:53:20 +02:00
project_src: traefik
state: present
pull: true
restarted: true
when: traefik_copy_files_results.changed or traefik_copy_templates_results.changed
2023-05-04 23:03:39 +02:00
become: true
2023-05-03 22:35:19 +02:00
- name: Update or start container
community.docker.docker_compose:
2023-05-20 15:53:20 +02:00
project_src: traefik
state: present
pull: true
when: not traefik_copy_files_results.changed and not traefik_copy_templates_results.changed
2023-05-03 22:35:19 +02:00
become: true