traefik/tasks/main.yml

48 lines
1.3 KiB
YAML

---
- name: "set local variables from overrides and defaults"
set_fact:
traefik: "{{ (traefik_defaults | combine(traefik_override, recursive=True)) if traefik_override else traefik_defaults }}"
- name: "Set arpa domain"
set_fact:
arpa_top_level: "{{ traefik.arpa_top_level | default(traefik.main_domain.split('.')[-2:] | join('.'), true) }}"
- name: ensure that path exists
file:
path: "{{ path }}/config/file_provider"
state: directory
- name: ensure that data exists
file:
path: "{{ path }}/data"
state: directory
- name: template docker-compose
template:
src: compose.yml.j2
dest: "{{ path }}/compose.yml"
- name: template traefik.yml
template:
src: traefik.yml.j2
dest: "{{ path }}/config/traefik.yml"
- name: Populate templates
template:
src: "configs/{{ item.path }}"
dest: "{{ path }}/config/file_provider/{{ item.path | regex_replace('\\.j2$', '') }}"
with_filetree: "{{ role_path }}/templates/configs"
when:
- item.state == "file"
- item.path | regex_replace('\\.yml\\.j2$', '') | basename in traefik.include_external_services.keys()
- name: ensure container is running
community.docker.docker_compose_v2:
project_src: "{{ path }}"
project_name: "{{ role_name }}"
state: "present"
pull: "always"
wait: true
services: ["traefik"]
register: _compose_result