-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraefik.yml
63 lines (57 loc) · 1.98 KB
/
traefik.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
- hosts: all
vars:
chemin_racine: "{{ ansible_env.HOME }}"
chemin_config: "{{ chemin_racine }}/traefik"
chemin_acme: "{{ chemin_racine }}/acme"
tasks:
- name: Crée les dossiers
file:
path: "{{ item }}"
state: directory
loop:
- "{{ chemin_acme }}"
- "{{ chemin_config }}"
- name: Copie le fichier de config
copy:
src: traefik.toml
dest: "{{ chemin_config }}"
- name: Crée le réseau traefik
docker_network:
name: traefik
- name: Démarre traefik
docker_container:
image: traefik:v1.7
name: traefik
restart_policy: always
pull: true
restart: true
published_ports:
- 443:443
- 80:80
networks:
- name: traefik
volumes:
- "{{ chemin_config }}/traefik.toml:/etc/traefik/traefik.toml"
- /var/run/docker.sock:/var/run/docker.sock
- "{{ chemin_acme }}:/etc/traefik/acme"
- name: Démarre les images qui redirigent les anciennes url
docker_container:
image: francois2/docker-nginx-redirect
name: "redirige-preprod-{{ item.nom }}"
restart_policy: always
restart: true
networks:
- name: traefik
env:
REDIRECT_URL: "https://{{ item.nouveau }}"
labels:
traefik.enable: 'true'
traefik.port: '80'
traefik.frontend.rule: "Host:{{ item.ancien }}"
traefik.docker.network: 'traefik'
loop:
- { nom: 'preprod-client', ancien: 'preprod.competences-pro.beta.gouv.fr', nouveau: 'preprod.eva.beta.gouv.fr' }
- { nom: 'preprod-serveur', ancien: 'apipreprod.competences-pro.beta.gouv.fr', nouveau: 'apipreprod.eva.beta.gouv.fr' }
- { nom: 'prod-client', ancien: 'competences-pro.beta.gouv.fr', nouveau: 'app.eva.beta.gouv.fr' }
- { nom: 'prod-serveur', ancien: 'api.competences-pro.beta.gouv.fr', nouveau: 'api.app.eva.beta.gouv.fr' }