homelab/roles/traefik/tasks/main.yml

31 lines
961 B
YAML
Raw Normal View History

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