38 lines
1.2 KiB
YAML
38 lines
1.2 KiB
YAML
- 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"
|
|
notify: restart_traefik
|
|
|
|
- name: Create Traefik network
|
|
docker_network:
|
|
name: traefik
|
|
|
|
- name: Start Traefik container
|
|
docker_container:
|
|
name: "{{ traefik_name }}"
|
|
image: traefik:{{ traefik_version }}
|
|
state: started
|
|
restart_policy: always
|
|
ports: "{{ traefik_ports }}"
|
|
networks_cli_compatible: "false"
|
|
networks:
|
|
- name: traefik
|
|
labels:
|
|
traefik.http.routers.traefik.rule: "Host(`{{ traefik_domain }}`)"
|
|
traefik.http.middlewares.auth.basicauth.users: "{{ traefik_auth }}"
|
|
traefik.http.routers.traefik.middlewares: "auth@docker"
|
|
traefik.http.routers.traefik.service: "api@internal"
|
|
traefik.http.routers.traefik.entrypoints: websecure
|
|
traefik.http.routers.traefik.tls: "true"
|
|
traefik.docker.network: traefik
|
|
traefik.enable: "{{ traefik_dashboard | string }}"
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- "{{ traefik_root }}/config:/etc/traefik"
|