Sfoglia il codice sorgente

Updated LE renewal hook system

Tomas Bedrich 8 anni fa
parent
commit
899f527ca3

+ 3
- 8
roles/common/files/etc_cron-daily_letsencrypt-renew Vedi File

@@ -3,11 +3,6 @@ set -o errexit
3 3
 # Renew all live certificates with LetsEncrypt.  This needs to run at least
4 4
 # once every three months, but recommended frequency is once a day.
5 5
 
6
-/root/letsencrypt/letsencrypt-auto renew --pre-hook="service apache2 stop" --post-hook="service apache2 start" \
7
-    -c /etc/letsencrypt/cli.conf
8
-
9
-# Services that rely on LE certificates may need restarted and/or other actions.
10
-for script in $(find /etc/letsencrypt/postrenew/ -maxdepth 1 -type f -executable); do
11
-  echo "Executing ${script}."
12
-  $script
13
-done
6
+/root/letsencrypt/letsencrypt-auto renew -c /etc/letsencrypt/cli.conf \
7
+--pre-hook="find /etc/letsencrypt/prerenew/ -maxdepth 1 -type f -executable -exec {} \;" \
8
+--post-hook="find /etc/letsencrypt/postrenew/ -maxdepth 1 -type f -executable -exec {} \;"

+ 24
- 5
roles/common/tasks/letsencrypt.yml Vedi File

@@ -19,16 +19,35 @@
19 19
   register: le_deps_result
20 20
   changed_when: "'Bootstrapping dependencies' in le_deps_result.stdout"
21 21
 
22
+- name: Create directory for pre-renewal scripts
23
+  file: state=directory path=/etc/letsencrypt/prerenew group=root owner=root
24
+
22 25
 - name: Create directory for post-renewal scripts
23 26
   file: state=directory path=/etc/letsencrypt/postrenew group=root owner=root
24 27
 
28
+- name: Create pre-renew hook to stop apache
29
+  copy:
30
+    content: "#!/bin/bash\n\nservice apache2 stop\n"
31
+    dest: /etc/letsencrypt/prerenew/apache
32
+    owner: root
33
+    group: root
34
+    mode: 0755
35
+
36
+- name: Create post-renew hook to start apache
37
+  copy:
38
+    content: "#!/bin/bash\n\nservice apache2 start\n"
39
+    dest: /etc/letsencrypt/postrenew/apache
40
+    owner: root
41
+    group: root
42
+    mode: 0755
43
+
25 44
 - name: Install crontab entry for LetsEncrypt
26 45
   copy:
27
-    src=etc_cron-daily_letsencrypt-renew
28
-    dest=/etc/cron.daily/letsencrypt-renew
29
-    owner=root
30
-    group=root
31
-    mode=0755
46
+    src: etc_cron-daily_letsencrypt-renew
47
+    dest: /etc/cron.daily/letsencrypt-renew
48
+    owner: root
49
+    group: root
50
+    mode: 0755
32 51
 
33 52
 - name: Create live directory for LetsEncrypt cron job
34 53
   file: state=directory path=/etc/letsencrypt/live group=root owner=root

Loading…
Annulla
Salva