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
|
2019-12-08 04:24:34 +00:00
|
|
|
|
2020-09-04 04:27:06 +00:00
|
|
|
- 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
|
|
|
|
|
2021-04-17 02:44:20 +00:00
|
|
|
- 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
|
|
|
|
|
2019-12-08 04:24:34 +00:00
|
|
|
- name: Create Traefik network
|
2019-12-03 00:39:13 +00:00
|
|
|
docker_network:
|
2020-07-11 07:38:45 +00:00
|
|
|
name: traefik
|
2019-12-03 00:39:13 +00:00
|
|
|
|
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 }}"
|
2019-11-01 00:29:09 +00:00
|
|
|
image: traefik:{{ traefik_version }}
|
2019-11-05 00:15:41 +00:00
|
|
|
state: started
|
2019-10-19 19:35:40 +00:00
|
|
|
restart_policy: always
|
2019-12-03 00:39:13 +00:00
|
|
|
ports: "{{ traefik_ports }}"
|
|
|
|
networks_cli_compatible: "false"
|
|
|
|
networks:
|
2020-07-11 07:38:45 +00:00
|
|
|
- name: traefik
|
2019-12-03 00:39:13 +00:00
|
|
|
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 }}"
|
2020-09-12 03:16:02 +00:00
|
|
|
traefik.http.middlewares.localonly.ipwhitelist.sourcerange: "{{ traefik_localonly }}"
|
2020-09-04 06:14:12 +00:00
|
|
|
traefik.http.routers.traefik.tls.certresolver: letsencrypt
|
2020-09-12 03:16:02 +00:00
|
|
|
traefik.http.routers.traefik.middlewares: "securehttps@file,auth@docker,localonly"
|
2019-12-03 00:39:13 +00:00
|
|
|
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"
|