aboutsummaryrefslogtreecommitdiff
path: root/roles/acme_client/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/acme_client/tasks')
-rw-r--r--roles/acme_client/tasks/main.yml63
1 files changed, 63 insertions, 0 deletions
diff --git a/roles/acme_client/tasks/main.yml b/roles/acme_client/tasks/main.yml
new file mode 100644
index 0000000..fb7ffd9
--- /dev/null
+++ b/roles/acme_client/tasks/main.yml
@@ -0,0 +1,63 @@
1---
2- block:
3 - name: Install acme-client and openssl
4 community.general.apk:
5 name:
6 - acme-client
7 - openssl
8 state: present
9 when: setup
10
11 - name: Ensure ACME directories exist
12 ansible.builtin.file:
13 path: "{{ item }}"
14 state: directory
15 owner: root
16 group: root
17 mode: '0755'
18 loop:
19 - /etc/ssl/private
20 - "{{ challengedir }}"
21 when: setup
22
23 - name: Deploy acme-client configuration
24 ansible.builtin.template:
25 src: acme-client.conf.j2
26 dest: /etc/acme-client.conf
27 owner: root
28 group: root
29 mode: '0644'
30 register: acme_client_conf
31 when: setup
32
33 - name: Generate self-signed fallback certificates if they do not exist
34 ansible.builtin.command:
35 cmd: "openssl req -new -x509 -keyout /etc/ssl/private/{{ item.domain }}.key -out /etc/ssl/{{ item.domain }}.fullchain.pem -days 365 -nodes -subj '/CN={{ item.domain }}'"
36 creates: "/etc/ssl/{{ item.domain }}.fullchain.pem"
37 loop: "{{ domains }}"
38 register: self_signed
39 when: setup
40
41 - name: Deploy weekly cron/periodic renewal script for acme-client
42 ansible.builtin.copy:
43 content: |
44 #!/bin/sh
45 # Run acme-client for each configured domain
46 {% for item in domains %}
47 acme-client -v {{ item.domain }}
48 {% endfor %}
49 dest: /etc/periodic/weekly/acme-client
50 owner: root
51 group: root
52 mode: '0755'
53 when: setup
54
55 - name: Try to renew Let's Encrypt certificates
56 ansible.builtin.command:
57 cmd: "acme-client -v {{ item.domain }}"
58 loop: "{{ domains }}"
59 when: not setup
60 ignore_errors: true
61
62 tags:
63 acme_client