blob: fb7ffd9e6b412286442d6f78ab94e63c9c42ad5e (
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
63
|
---
- block:
- name: Install acme-client and openssl
community.general.apk:
name:
- acme-client
- openssl
state: present
when: setup
- name: Ensure ACME directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: '0755'
loop:
- /etc/ssl/private
- "{{ challengedir }}"
when: setup
- name: Deploy acme-client configuration
ansible.builtin.template:
src: acme-client.conf.j2
dest: /etc/acme-client.conf
owner: root
group: root
mode: '0644'
register: acme_client_conf
when: setup
- name: Generate self-signed fallback certificates if they do not exist
ansible.builtin.command:
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 }}'"
creates: "/etc/ssl/{{ item.domain }}.fullchain.pem"
loop: "{{ domains }}"
register: self_signed
when: setup
- name: Deploy weekly cron/periodic renewal script for acme-client
ansible.builtin.copy:
content: |
#!/bin/sh
# Run acme-client for each configured domain
{% for item in domains %}
acme-client -v {{ item.domain }}
{% endfor %}
dest: /etc/periodic/weekly/acme-client
owner: root
group: root
mode: '0755'
when: setup
- name: Try to renew Let's Encrypt certificates
ansible.builtin.command:
cmd: "acme-client -v {{ item.domain }}"
loop: "{{ domains }}"
when: not setup
ignore_errors: true
tags:
acme_client
|