blob: 1346675f181e4dacc283011ab1476c1d5d7c4310 (
plain) (
blame)
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
|
---
- name: generate simple ssl key and self-signed certificate
ansible.builtin.command:
cmd: |
openssl req
-x509
-newkey rsa:4096
-nodes
-subj "/CN={{ item.domain }}"
-keyout {{ relayd_ssl_keys_dir }}/{{ item.domain }}.key
-out {{ relayd_ssl_certificates_dir }}/{{ item.domain }}.pem
creates: "{{ relayd_ssl_keys_dir }}/{{ item.domain }}.key"
loop: "{{ relayd_rules }}"
- name: apply restrictive permissions on ssl keys
ansible.builtin.file:
path: "{{ relayd_ssl_keys_dir }}/{{ item.domain }}.key"
owner: 0
group: 0
mode: "0600"
loop: "{{ relayd_rules }}"
- name: retrieve certificate files
ansible.builtin.stat:
path: "{{ relayd_ssl_certificates_dir }}/{{ item.domain }}.crt"
loop: "{{ relayd_rules }}"
register: relayd_result_stat_certificates
- name: link pem files to certificate files if required
ansible.builtin.file:
src: "{{ relayd_ssl_certificates_dir }}/{{ item.item.domain }}.pem"
dest: "{{ item.invocation.module_args.path }}"
owner: 0
group: 0
state: link
when: not item.stat.exists
loop: "{{ relayd_result_stat_certificates.results }}"
- name: generate relayd configuration
ansible.builtin.template:
src: relayd.conf.j2
dest: "{{ relayd_configuration_file }}"
owner: 0
group: 0
mode: "0640"
register: relayd_result_generate_configuration
- name: lint relayd configuration
ansible.builtin.command: "relayd -nf {{ relayd_configuration_file }}"
register: relayd_result_lint_configuration
changed_when:
- relayd_result_generate_configuration.changed
- relayd_result_lint_configuration.rc != 0
- name: restart relayd # noqa: no-handler
ansible.builtin.service:
name: relayd
state: restarted
when: relayd_result_generate_configuration.changed
or relayd_result_lint_configuration.changed
- name: enable relayd
ansible.builtin.service:
name: relayd
enabled: true
|