demo_ansible/roles/traefik/tasks/main.yml

27 lines
972 B
YAML

---
- name: Create service directory if needed
ansible.builtin.file: { path: "/opt/service/{{ docker_compose.project_name }}", state: directory, mode: '0700' }
- name: create traefik network
community.general.docker_network:
name: "traefik"
- name: Copy config file
ansible.builtin.copy: { src: "traefik.yml", dest: "{{ docker_compose.path }}/traefik.yml" }
notify: [ "Stop {{ docker_compose.project_name }}", "Start {{ docker_compose.project_name }}" ]
- name: Copy logrotate traefik config
ansible.builtin.copy: { src: "traefik", dest: "/etc/logrotate.d/" }
- name: Copy docker compose files
ansible.builtin.template:
src: "{{ docker_compose.file }}.j2"
dest: "{{ docker_compose.path }}/{{ docker_compose.file }}"
mode: "u=rw,go-rwx"
validate: docker-compose -f %s config
notify: [ "Stop {{ docker_compose.project_name }}", "Start {{ docker_compose.project_name }}" ]
- name: Flush handlers
ansible.builtin.meta: flush_handlers