homelab/roles/traefik/tasks/main.yml
2024-03-26 23:46:29 -04:00

37 lines
1.0 KiB
YAML

- name: Create Traefik directories
ansible.builtin.file:
path: "{{ traefik_root }}/config/dynamic"
mode: 0500
state: directory
- name: Install dynamic security configuration
ansible.builtin.template:
src: security.yml.j2
dest: "{{ traefik_root }}/config/dynamic/security.yml"
owner: root
group: root
mode: 0400
notify: reload_traefik
- name: Install dynamic non-docker configuration
ansible.builtin.template:
src: "external.yml.j2"
dest: "{{ traefik_root }}/config/dynamic/{{ item.name }}.yml"
mode: 0400
loop: "{{ traefik_external }}"
when: traefik_external is defined
- name: Install static Traefik configuration
ansible.builtin.template:
src: traefik.yml.j2
dest: "{{ traefik_root }}/config/traefik.yml"
mode: 0400
notify: restart_traefik
- name: Start Traefik service and enable on boot
ansible.builtin.service:
name: "{{ docker_compose_service }}@{{ traefik_name }}"
state: started
enabled: true
when: traefik.ENABLED | default('false')