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 ---
- name: "Create file: /usr/local/bin/acme-redirect-fixpermissions"
copy:
content: "#!/bin/sh\n/bin/chown -R acme-redirect:acme-redirect /var/lib/acme-redirect/live\n/bin/chown -R acme-redirect:acme-redirect /var/lib/acme-redirect/certs"
dest: /usr/local/bin/acme-redirect-fixpermissions
mode: 0755
- name: "[Alpine] create sudoers file for acme-redirect"
copy:
content: "acme-redirect ALL=NOPASSWD:/sbin/rc-service,/usr/local/bin/acme-redirect-fixpermissions\n"
dest: /etc/sudoers.d/acme-redirect
when:
- ansible_distribution == "Alpine"
- name: "[Archlinux] create sudoers file for acme-redirect"
copy:
content: "acme-redirect ALL=NOPASSWD:/usr/bin/systemctl,/usr/local/bin/acme-redirect-fixpermissions\n"
dest: /etc/sudoers.d/acme-redirect
when:
- ansible_distribution == "Archlinux"
- name: "Create file: /etc/acme-redirect.conf"
template:
src: acme-redirect-general.conf.j2
dest: /etc/acme-redirect.conf
owner: acme-redirect
group: acme-redirect
notify: "Restart acme-redirect"
- name: "Create directory: /etc/acme-redirect.d"
file:
state: "directory"
path: /etc/acme-redirect.d
owner: acme-redirect
group: acme-redirect
mode: 0755
when:
- services.acme_redirect.certs is defined
- name: Generate acme-redirect cert configs
template:
src: acme-redirect.conf.j2
dest: /etc/acme-redirect.d/{{item.key}}.conf
owner: acme-redirect
group: acme-redirect
mode: 0644
loop: "{{ lookup('dict', services.acme_redirect.certs, wantlist=True) }}"
register: acme_redirect_deployed_configs
notify: "Restart acme-redirect"
when:
- services.acme_redirect.certs is defined
- name: "Collect files in directory: /etc/acme-redirect.d"
find:
path: /etc/acme-redirect.d
hidden: yes
register: acme_redirect_found_files
check_mode: no
changed_when: false
when:
- services.acme_redirect.certs is defined
- name: "Remove unmanaged files in directory: /etc/acme-redirect.d"
file:
path: "/etc/acme-redirect.d/{{ item.path | basename }}"
state: absent
with_items:
- "{{ acme_redirect_found_files.files }}"
notify: "Restart acme-redirect"
when:
- services.acme_redirect.certs is defined
- (item.path) not in ( acme_redirect_deployed_configs | json_query('results[].invocation.module_args.dest') | default([]) )