summaryrefslogtreecommitdiffstats
path: root/roles/common/tasks/munin-node-ssl.yml
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-05-11 18:07:09 +0200
committerGuilhem Moulin <guilhem@fripost.org>2016-05-12 11:33:55 +0200
commit90d498034b891123350785a134402172de477f4f (patch)
treea6e3c924054c3f689cdaffffe3a479e88fb97282 /roles/common/tasks/munin-node-ssl.yml
parente370313ad5895871479fffc922e3c72c0375dbf2 (diff)
Use systemd unit files for stunnel4.
Diffstat (limited to 'roles/common/tasks/munin-node-ssl.yml')
-rw-r--r--roles/common/tasks/munin-node-ssl.yml58
1 files changed, 58 insertions, 0 deletions
diff --git a/roles/common/tasks/munin-node-ssl.yml b/roles/common/tasks/munin-node-ssl.yml
new file mode 100644
index 0000000..59ed7d7
--- /dev/null
+++ b/roles/common/tasks/munin-node-ssl.yml
@@ -0,0 +1,58 @@
+- name: Create /etc/stunnel/certs
+ file: path=/etc/stunnel/certs
+ state=directory
+ owner=root group=root
+ mode=0755
+
+- name: Generate a private key and a X.509 certificate for munin-node
+ command: genkeypair.sh x509
+ --pubkey=/etc/stunnel/certs/munin-{{ inventory_hostname_short }}.pem
+ --privkey=/etc/stunnel/certs/munin-{{ inventory_hostname_short }}.key
+ --ou=Munin --cn={{ inventory_hostname }} --dns={{ inventory_hostname }}
+ -t rsa -b 4096 -h sha512
+ register: r1
+ changed_when: r1.rc == 0
+ failed_when: r1.rc > 1
+ notify:
+ - Restart stunnel@munin-node
+ tags:
+ - genkey
+
+- name: Fetch Munin X.509 certificate
+ # Ensure we don't fetch private data
+ become: False
+ fetch: src=/etc/stunnel/certs/munin-{{ inventory_hostname_short }}.pem
+ dest=certs/munin/{{ inventory_hostname }}.pem
+ fail_on_missing=yes
+ flat=yes
+ tags:
+ - genkey
+
+- name: Copy munin-master X.509 certificates
+ assemble: src=certs/munin regexp="{{ groups['munin-master'] | join('|') }}\.pem$" remote_src=no
+ dest=/etc/stunnel/certs/munin-master.pem
+ owner=root group=root
+ mode=0644
+ register: r2
+ when: "'munin-master' not in group_names"
+ notify:
+ - Restart stunnel@munin-node
+
+- name: Configure stunnel
+ template: src=etc/stunnel/munin-node.conf.j2
+ dest=/etc/stunnel/munin-node.conf
+ owner=root group=root
+ mode=0644
+ register: r3
+ when: "'munin-master' not in group_names"
+ notify:
+ - Restart stunnel@munin-node
+
+- name: Enable stunnel@munin-node
+ service: name=stunnel4@munin-node enabled=yes
+
+- name: Start stunnel@munin-node
+ service: name=stunnel4@munin-node state=started
+ when: not (r1.changed or r2.changed or r3.changed)
+
+- meta: flush_handlers