homelab/roles/traefik/tasks/main.yml

50 lines
1.3 KiB
YAML
Raw Permalink Normal View History

- name: Create Traefik directories
2023-05-04 03:42:55 +00:00
ansible.builtin.file:
2020-07-17 04:41:21 +00:00
path: "{{ traefik_root }}/config/dynamic"
2023-05-04 05:44:18 +00:00
mode: 0500
2020-07-17 04:41:21 +00:00
state: directory
- name: Install dynamic security configuration
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: security.yml.j2
dest: "{{ traefik_root }}/config/dynamic/security.yml"
2020-09-04 03:26:55 +00:00
owner: root
group: root
2023-05-04 05:44:18 +00:00
mode: 0400
2020-09-04 03:26:55 +00:00
notify: reload_traefik
- name: Install dynamic non-docker configuration
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: "external.yml.j2"
dest: "{{ traefik_root }}/config/dynamic/{{ item.name }}.yml"
2023-05-04 05:44:18 +00:00
mode: 0400
loop: "{{ traefik_external }}"
when: traefik_external is defined
- name: Install Traefik's docker-compose file
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: docker-compose.yml.j2
dest: "{{ traefik_root }}/docker-compose.yml"
2023-05-04 05:44:18 +00:00
mode: 0400
notify: restart_traefik
- name: Install Traefik's docker-compose variables
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: compose-env.j2
dest: "{{ traefik_root }}/.env"
2023-05-04 05:44:18 +00:00
mode: 0400
notify: restart_traefik
- name: Install static Traefik configuration
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: traefik.yml.j2
dest: "{{ traefik_root }}/config/traefik.yml"
2023-05-04 05:44:18 +00:00
mode: 0400
notify: restart_traefik
- name: Start and enable Traefik service
2023-05-04 03:42:55 +00:00
ansible.builtin.service:
name: "{{ docker_compose_service }}@{{ traefik_name }}"
state: started
enabled: true