blob: 5606b60810f01ceb648bf9de42218b5da498508e (
plain)
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
|
- name: check required variables
fail:
msg: "value of {{ item }} should no be FIXME!"
with_items:
- letsencrypt_domain
- letsencrypt_email
- letsencrypt_server
when: item == "FIXME"
- name: install deploy_certs_haproxy
template:
src: deploy_certs_haproxy
dest: /usr/local/sbin/deploy_certs_haproxy
owner: root
group: root
mode: 0755
- name: install certbot
apt:
name: certbot
default_release: stretch-backports
- name: install haproxy
apt:
name: haproxy
- name: stop haproxy
ignore_errors: true
systemd:
name: haproxy
state: stopped
- name: fetch new certificate
command: >
certbot certonly
--standalone
--noninteractive
--domain "{{ letsencrypt_domain }}"
--email "{{ letsencrypt_email }}"
--agree-tos
- name: install new cert for haproxy
command: /usr/local/sbin/deploy_certs_haproxy
- name: start haproxy
ignore_errors: true
systemd:
name: haproxy
state: started
- name: add cron job
cron:
name: letsencrypt
hour: 23
minute: 42
user: root
job: >
certbot renew
--standalone
--quiet
--pre-hook "systemctl stop haproxy"
--post-hook "/usr/local/sbin/deploy_certs_haproxy && systemctl start haproxy"
|