Playbook d'installation de Traefik.
This commit is contained in:
commit
c1bc15d0a9
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/playbook.retry
|
||||
/hosts.ini
|
||||
11
hosts.example.ini
Normal file
11
hosts.example.ini
Normal file
@ -0,0 +1,11 @@
|
||||
[webservers]
|
||||
example.com
|
||||
|
||||
[webservers:vars]
|
||||
ansible_python_interpreter=/usr/bin/python3
|
||||
|
||||
user=ubuntu
|
||||
group=docker
|
||||
path=/srv/traefik
|
||||
|
||||
acme_email=admin@example.com
|
||||
48
playbook.yml
Normal file
48
playbook.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Install traefik
|
||||
hosts: webservers
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Create directory
|
||||
file:
|
||||
path: "{{ path }}"
|
||||
state: directory
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
|
||||
- name: Create acme file
|
||||
file:
|
||||
path: "{{ path }}/acme.json"
|
||||
state: touch
|
||||
mode: 0600
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
|
||||
- name: Add config file
|
||||
template:
|
||||
src: traefik.toml.j2
|
||||
dest: "{{ path }}/traefik.toml"
|
||||
mode: 0600
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
|
||||
- name: Create network
|
||||
docker_network:
|
||||
name: web
|
||||
|
||||
- name: Create container
|
||||
docker_container:
|
||||
name: traefik
|
||||
image: traefik:2.4
|
||||
restart_policy: unless-stopped
|
||||
recreate: true
|
||||
networks:
|
||||
- name: web
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- "{{ path }}/traefik.toml:/etc/traefik/traefik.toml"
|
||||
- "{{ path }}/acme.json:/acme.json"
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
17
readme.md
Normal file
17
readme.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Ansible: Setup Traefik v2.x
|
||||
|
||||
This playbook installs Traefik on your server.
|
||||
|
||||
## Installing
|
||||
|
||||
Copy then change values of hosts example file
|
||||
|
||||
```bash
|
||||
$ cp hosts.example.ini hosts.ini
|
||||
```
|
||||
|
||||
Then run the playbook:
|
||||
|
||||
```bash
|
||||
$ ansible-playbook -i hosts.ini playbook.yml
|
||||
```
|
||||
15
traefik.toml.j2
Normal file
15
traefik.toml.j2
Normal file
@ -0,0 +1,15 @@
|
||||
[entryPoints]
|
||||
[entryPoints.http]
|
||||
address = ":80"
|
||||
[entryPoints.https]
|
||||
address = ":443"
|
||||
|
||||
[providers.docker]
|
||||
network = "web"
|
||||
endpoint = "unix:///var/run/docker.sock"
|
||||
|
||||
[certificatesResolvers.letsencrypt.acme]
|
||||
email = "{{ acme_email }}"
|
||||
storage = "acme.json"
|
||||
[certificatesResolvers.letsencrypt.acme.httpChallenge]
|
||||
entryPoint = "http"
|
||||
Loading…
x
Reference in New Issue
Block a user