-
Notifications
You must be signed in to change notification settings - Fork 0
/
traefik.yaml
100 lines (96 loc) · 2.56 KB
/
traefik.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
- name: Update and upgrade installed packages
hosts: proxy
become: yes
tasks:
- apt:
upgrade: true
update_cache: true
- name: Download Traefik from GitHub.com
hosts: proxy
become: yes
tasks:
- name: Download and extract Traefik
ansible.builtin.unarchive:
src: https://github.com/traefik/traefik/releases/download/v3.0.1/traefik_v3.0.1_linux_amd64.tar.gz
dest: /usr/local/bin
remote_src: 'True'
- name: Apply correct permissions
ansible.builtin.file:
path: /usr/local/bin/traefik
owner: root
group: root
mode: '0755'
- name: Set cap_net_bind_service=+ep
community.general.capabilities:
path: /usr/local/bin/traefik
capability: cap_net_bind_service=+ep
state: present
- name: Setup Traefik user
hosts: proxy
become: yes
tasks:
- name: Ensure group "traefik" exists with correct gid
ansible.builtin.group:
name: traefik
state: present
gid: 321
- name: Ensure user "traefik" exists with correct uid
ansible.builtin.user:
name: traefik
group: traefik
uid: 321
shell: /usr/sbin/nologin
create_home: 'False'
system: 'True'
- name: Setup directories and configuration files
hosts: proxy
become: yes
tasks:
- name: Create /etc/traefik
ansible.builtin.file:
path: /etc/traefik
state: directory
mode: '0755'
owner: root
group: root
- name: Create /etc/traefik/acme
ansible.builtin.file:
path: /etc/traefik/acme
state: directory
mode: '0750'
owner: traefik
group: traefik
- name: Copy the Traefik config file
ansible.builtin.copy:
src: ./traefik.toml
dest: /etc/traefik/traefik.toml
mode: '640'
owner: traefik
group: traefik
- name: Create Traefik log file
ansible.builtin.file:
path: /var/log/traefik.log
state: touch
mode: '640'
owner: traefik
group: traefik
modification_time: preserve
access_time: preserve
- name: Configure Systemd
hosts: proxy
become: yes
tasks:
- name: Copy the Systemd unit file
ansible.builtin.copy:
src: ./traefik.service
dest: /etc/systemd/system/traefik.service
mode: '644'
owner: root
group: root
- name: Start and enable the service
ansible.builtin.service:
name: traefik.service
state: restarted
enabled: true
daemon_reload: 'True'