2019-12-08 04:24:34 +00:00
|
|
|
- name: Set default Traefik options
|
|
|
|
set_fact:
|
|
|
|
traefik_defaults:
|
|
|
|
- "--providers.docker"
|
|
|
|
- "--providers.docker.exposedbydefault=false"
|
|
|
|
|
|
|
|
- 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-12-08 04:24:34 +00:00
|
|
|
command: "{{ traefik_defaults + traefik_options }}"
|
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 }}"
|
|
|
|
traefik.http.routers.traefik.middlewares: "auth@docker"
|
2019-12-03 00:39:13 +00:00
|
|
|
traefik.http.routers.traefik.service: "api@internal"
|
2020-07-11 07:38:45 +00:00
|
|
|
traefik.docker.network: traefik
|
2019-12-03 00:39:13 +00:00
|
|
|
traefik.enable: "true"
|
2019-10-19 19:35:40 +00:00
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|