homelab/roles/traefik/tasks/main.yml

56 lines
1.8 KiB
YAML
Raw Permalink Normal View History

2020-07-17 04:41:21 +00:00
- name: Create Traefik configuration directories
file:
path: "{{ traefik_root }}/config/dynamic"
state: directory
- name: Install static Traefik configuration
template:
src: traefik.yml.j2
dest: "{{ traefik_root }}/config/traefik.yml"
2020-09-03 23:00:27 +00:00
notify: restart_traefik
- name: Install dynamic security configuration
template:
src: security.yml.j2
dest: "{{ traefik_root }}/config/dynamic/security.yml"
2020-09-04 03:26:55 +00:00
owner: root
group: root
mode: 0600
notify: reload_traefik
- name: Install dynamic non-docker configuration
template:
src: "external.yml.j2"
dest: "{{ traefik_root }}/config/dynamic/{{ item.name }}.yml"
loop: "{{ traefik_external }}"
when: traefik_external is defined
- name: Create Traefik network
docker_network:
2020-07-11 07:38:45 +00:00
name: traefik
2019-10-19 19:35:40 +00:00
- name: Start Traefik container
docker_container:
2019-11-03 03:34:03 +00:00
name: "{{ traefik_name }}"
image: traefik:{{ traefik_version }}
state: started
2019-10-19 19:35:40 +00:00
restart_policy: always
ports: "{{ traefik_ports }}"
networks_cli_compatible: "false"
networks:
2020-07-11 07:38:45 +00:00
- name: traefik
labels:
traefik.http.routers.traefik.rule: "Host(`{{ traefik_domain }}`)"
2019-12-23 22:22:24 +00:00
traefik.http.middlewares.auth.basicauth.users: "{{ traefik_auth }}"
traefik.http.middlewares.localonly.ipwhitelist.sourcerange: "{{ traefik_localonly }}"
traefik.http.routers.traefik.tls.certresolver: letsencrypt
traefik.http.routers.traefik.middlewares: "securehttps@file,auth@docker,localonly"
traefik.http.routers.traefik.service: "api@internal"
2020-07-17 04:41:21 +00:00
traefik.http.routers.traefik.entrypoints: websecure
traefik.http.routers.traefik.tls: "true"
2020-07-11 07:38:45 +00:00
traefik.docker.network: traefik
2020-07-11 08:31:34 +00:00
traefik.enable: "{{ traefik_dashboard | string }}"
2019-10-19 19:35:40 +00:00
volumes:
- /var/run/docker.sock:/var/run/docker.sock
2020-07-17 04:41:21 +00:00
- "{{ traefik_root }}/config:/etc/traefik"