add simple traefik stack

This commit is contained in:
Pim Kunis 2023-05-02 12:22:16 +02:00
parent b8afb2ac64
commit 4678724dcf
4 changed files with 63 additions and 1 deletions

View file

@ -1,6 +1,7 @@
docker_node_labels:
- hostname: maestro
labels: {}
labels:
traefik: "true"
- hostname: worker1
labels: {}

View file

@ -0,0 +1,5 @@
---
- name: Start Docker stacks
hosts: manager
roles:
- {role: traefik, tags: traefik}

View file

@ -0,0 +1,36 @@
# vi: ft=yaml
version: "3.7"
networks:
traefik:
external: true
services:
traefik:
image: traefik:3.0
networks:
- traefik
ports:
- 80:80
- 8080:8080
deploy:
placement:
constraints: [node.labels.traefik == true]
labels:
- traefik.enable=true
- traefik.http.routers.dashboard.rule=Host(`maestro.dmz`)
- traefik.http.routers.dashboard.service=api@internal
- traefik.http.services.dummy-svc.loadbalancer.server.port=8080
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
command:
- --providers.docker
- --providers.docker.swarmmode
- --providers.docker.watch
- --api
- --api.insecure=true
- --api.dashboard=true
- --entrypoints.web.address=:80
- --providers.docker.exposedbydefault=false

View file

@ -0,0 +1,20 @@
- name: Create Traefik network
docker_network:
name: traefik
driver: overlay
- name: Create working directory
file:
path: /srv/traefik
state: directory
- name: Copy Docker stack file
template:
src: "{{ role_path }}/docker-stack.yml.j2"
dest: /srv/traefik/docker-stack.yml
- name: Deploy Docker stack
docker_stack:
name: traefik
compose:
- /srv/traefik/docker-stack.yml