add simple traefik stack
This commit is contained in:
parent
b8afb2ac64
commit
4678724dcf
4 changed files with 63 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
docker_node_labels:
|
docker_node_labels:
|
||||||
- hostname: maestro
|
- hostname: maestro
|
||||||
labels: {}
|
labels:
|
||||||
|
traefik: "true"
|
||||||
- hostname: worker1
|
- hostname: worker1
|
||||||
labels: {}
|
labels: {}
|
||||||
|
|
||||||
|
|
5
ansible/playbooks/stacks.yml
Normal file
5
ansible/playbooks/stacks.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Start Docker stacks
|
||||||
|
hosts: manager
|
||||||
|
roles:
|
||||||
|
- {role: traefik, tags: traefik}
|
36
ansible/roles/traefik/docker-stack.yml.j2
Normal file
36
ansible/roles/traefik/docker-stack.yml.j2
Normal 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
|
20
ansible/roles/traefik/tasks/main.yml
Normal file
20
ansible/roles/traefik/tasks/main.yml
Normal 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
|
Reference in a new issue