From cb3abd557431cc04aef5de1b302bcde25cd81c81 Mon Sep 17 00:00:00 2001 From: Niklas Yann Wettengel Date: Sat, 25 Mar 2017 14:33:23 +0100 Subject: added reload and restart handlers --- roles/configure_iptables/handlers/main.yml | 10 ++++++++++ roles/configure_iptables/tasks/main.yml | 10 ++++------ roles/configure_journald/handlers/main.yml | 5 +++++ roles/configure_journald/tasks/main.yml | 8 +------- roles/configure_sysctl/handlers/main.yml | 3 +++ roles/configure_sysctl/tasks/main.yml | 6 +----- roles/install_bind/handlers/main.yml | 5 +++++ roles/install_bind/tasks/main.yml | 8 +------- roles/install_dhcp/handlers/main.yml | 5 +++++ roles/install_dhcp/tasks/main.yml | 1 + roles/install_fastd/handlers/main.yml | 10 ++++++++++ roles/install_fastd/tasks/main.yml | 4 ++++ roles/install_monitoring/handlers/munin.yml | 5 +++++ roles/install_monitoring/tasks/install_munin.yml | 4 ++++ roles/install_monitoring/tasks/install_vnstat.yml | 10 ++-------- roles/install_nginx/handlers/main.yml | 5 +++++ roles/install_nginx/tasks/main.yml | 1 + roles/install_openvpn/handlers/main.yml | 5 +++++ roles/install_openvpn/tasks/main.yml | 6 ++++++ 19 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 roles/configure_iptables/handlers/main.yml create mode 100644 roles/configure_journald/handlers/main.yml create mode 100644 roles/configure_sysctl/handlers/main.yml create mode 100644 roles/install_bind/handlers/main.yml create mode 100644 roles/install_dhcp/handlers/main.yml create mode 100644 roles/install_fastd/handlers/main.yml create mode 100644 roles/install_monitoring/handlers/munin.yml create mode 100644 roles/install_nginx/handlers/main.yml create mode 100644 roles/install_openvpn/handlers/main.yml diff --git a/roles/configure_iptables/handlers/main.yml b/roles/configure_iptables/handlers/main.yml new file mode 100644 index 0000000..63f34e9 --- /dev/null +++ b/roles/configure_iptables/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: reload iptables + systemd: + name: iptables.service + state: reloaded + +- name: reload ip6tables + systemd: + name: ip6tables.service + state: reloaded diff --git a/roles/configure_iptables/tasks/main.yml b/roles/configure_iptables/tasks/main.yml index 34f6c27..e0e6625 100644 --- a/roles/configure_iptables/tasks/main.yml +++ b/roles/configure_iptables/tasks/main.yml @@ -3,24 +3,22 @@ copy: src: iptables.rules dest: /etc/iptables/iptables.rules - register: iptables_rules + notify: reload iptables - name: start and enable iptables service - when: iptables_rules.changed systemd: name: iptables.service enabled: yes - state: reloaded + state: started - name: copy ip6tables.rules copy: src: ip6tables.rules dest: /etc/iptables/ip6tables.rules - register: ip6tables_rules + notify: reload ip6tables - name: start and enable ip6tables service - when: ip6tables_rules.changed systemd: name: ip6tables.service enabled: yes - state: reloaded + state: started diff --git a/roles/configure_journald/handlers/main.yml b/roles/configure_journald/handlers/main.yml new file mode 100644 index 0000000..37a6c72 --- /dev/null +++ b/roles/configure_journald/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart systemd-journald + systemd: + name: systemd-journald.service + state: restarted diff --git a/roles/configure_journald/tasks/main.yml b/roles/configure_journald/tasks/main.yml index 6742a9c..a9976d6 100644 --- a/roles/configure_journald/tasks/main.yml +++ b/roles/configure_journald/tasks/main.yml @@ -4,10 +4,4 @@ path: /etc/systemd/journald.conf regexp: '^#?Storage=' line: 'Storage=volatile' - register: journald_conf - -- name: restart systemd-journald - when: journald_conf.changed - systemd: - name: systemd-journald.service - state: restarted + notify: restart systemd-journald diff --git a/roles/configure_sysctl/handlers/main.yml b/roles/configure_sysctl/handlers/main.yml new file mode 100644 index 0000000..1b892d7 --- /dev/null +++ b/roles/configure_sysctl/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: reload ff-sysctl + command: /usr/bin/sysctl -p /etc/sysctl.d/ff.conf diff --git a/roles/configure_sysctl/tasks/main.yml b/roles/configure_sysctl/tasks/main.yml index 1bfa275..04e0bef 100644 --- a/roles/configure_sysctl/tasks/main.yml +++ b/roles/configure_sysctl/tasks/main.yml @@ -9,8 +9,4 @@ copy: src: ff.conf dest: /etc/sysctl.d/ff.conf - register: ff_conf - -- name: reload sysctl - when: ff_conf.changed - command: /usr/bin/sysctl -p /etc/sysctl.d/ff.conf + notify: reload ff-sysctl diff --git a/roles/install_bind/handlers/main.yml b/roles/install_bind/handlers/main.yml new file mode 100644 index 0000000..8fb0c88 --- /dev/null +++ b/roles/install_bind/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: reload bind + systemd: + name: named.service + state: reloaded diff --git a/roles/install_bind/tasks/main.yml b/roles/install_bind/tasks/main.yml index 31a833c..a7391e5 100644 --- a/roles/install_bind/tasks/main.yml +++ b/roles/install_bind/tasks/main.yml @@ -15,10 +15,4 @@ template: src: named.conf.j2 dest: /etc/named.conf - register: named_conf - -- name: reload bind - when: named_conf.changed - systemd: - name: named.service - state: reloaded + notify: reload bind diff --git a/roles/install_dhcp/handlers/main.yml b/roles/install_dhcp/handlers/main.yml new file mode 100644 index 0000000..8b2349a --- /dev/null +++ b/roles/install_dhcp/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart dhcpd4 + systemd: + name: dhcpd4.service + state: restarted diff --git a/roles/install_dhcp/tasks/main.yml b/roles/install_dhcp/tasks/main.yml index 2773e30..2e85106 100644 --- a/roles/install_dhcp/tasks/main.yml +++ b/roles/install_dhcp/tasks/main.yml @@ -27,3 +27,4 @@ template: src: dhcpd.conf.j2 dest: /etc/dhcpd.conf + notify: restart dhcpd4 diff --git a/roles/install_fastd/handlers/main.yml b/roles/install_fastd/handlers/main.yml new file mode 100644 index 0000000..e8051bc --- /dev/null +++ b/roles/install_fastd/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: reload fastd + systemd: + name: fastd@ffmyk.service + state: reloaded + +- name: restart fastd + systemd: + name: fastd@ffmyk.service + state: restarted diff --git a/roles/install_fastd/tasks/main.yml b/roles/install_fastd/tasks/main.yml index c6434d0..4a0a131 100644 --- a/roles/install_fastd/tasks/main.yml +++ b/roles/install_fastd/tasks/main.yml @@ -16,6 +16,8 @@ src: fastd.conf.j2 dest: /etc/fastd/ffmyk/fastd.conf mode: 0640 + notify: restart fastd + - name: create backbone folder file: path: /etc/fastd/ffmyk/backbone @@ -41,6 +43,7 @@ - fastd13 - fastd14 - fastd15 + notify: reload fastd - name: add fastd bin folder file: @@ -52,6 +55,7 @@ src: fastd_up.sh.j2 dest: /etc/fastd/ffmyk/bin/up.sh mode: 0744 + notify: restart fastd - name: add fastd peers folder file: diff --git a/roles/install_monitoring/handlers/munin.yml b/roles/install_monitoring/handlers/munin.yml new file mode 100644 index 0000000..d0f2d58 --- /dev/null +++ b/roles/install_monitoring/handlers/munin.yml @@ -0,0 +1,5 @@ +--- +- name: restart munin-node + systemd: + name: munin-node.service + state: restarted diff --git a/roles/install_monitoring/tasks/install_munin.yml b/roles/install_monitoring/tasks/install_munin.yml index 1b442dc..bda0e6f 100644 --- a/roles/install_monitoring/tasks/install_munin.yml +++ b/roles/install_monitoring/tasks/install_munin.yml @@ -8,6 +8,7 @@ template: src: munin-node.conf.j2 dest: /etc/munin/munin-node.conf + notify: restart munin-node - name: copy fastd plugin copy: @@ -25,11 +26,13 @@ copy: src: munin/munin_fastd_conf dest: /etc/munin/plugin-conf.d/fastd + notify: restart munin-node - name: copy global config copy: src: munin/munin_global_conf dest: /etc/munin/plugin-conf.d/global + notify: restart munin-node - name: install netstat pacman: @@ -52,6 +55,7 @@ src: /usr/lib/munin/plugins/{{ item.plugin | default( item.name ) }} state: link with_items: "{{ munin_node_plugins }}" + notify: restart munin-node - name: start and enable munin-node systemd: diff --git a/roles/install_monitoring/tasks/install_vnstat.yml b/roles/install_monitoring/tasks/install_vnstat.yml index 0198403..9113331 100644 --- a/roles/install_monitoring/tasks/install_vnstat.yml +++ b/roles/install_monitoring/tasks/install_vnstat.yml @@ -48,17 +48,11 @@ copy: src: vnstat dest: /etc/nginx/sites-available/vnstat - register: nginx_config + notify: reload nginx - name: enable vnstat nginx config file: src: /etc/nginx/sites-available/vnstat dest: /etc/nginx/sites-enabled/vnstat state: link - -- name: reload nginx - when: nginx_config.changed - systemd: - name: nginx.service - state: reloaded - + notify: reload nginx diff --git a/roles/install_nginx/handlers/main.yml b/roles/install_nginx/handlers/main.yml new file mode 100644 index 0000000..04f4ea0 --- /dev/null +++ b/roles/install_nginx/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: reload nginx + systemd: + name: nginx.service + state: reloaded diff --git a/roles/install_nginx/tasks/main.yml b/roles/install_nginx/tasks/main.yml index 5b8fe65..1e21bec 100644 --- a/roles/install_nginx/tasks/main.yml +++ b/roles/install_nginx/tasks/main.yml @@ -8,6 +8,7 @@ copy: src: nginx.conf dest: /etc/nginx/nginx.conf + notify: reload nginx - name: add sites-available folder file: diff --git a/roles/install_openvpn/handlers/main.yml b/roles/install_openvpn/handlers/main.yml new file mode 100644 index 0000000..da582dc --- /dev/null +++ b/roles/install_openvpn/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart openvpn + systemd: + name: openvpn-client@mullvad.service + state: restarted diff --git a/roles/install_openvpn/tasks/main.yml b/roles/install_openvpn/tasks/main.yml index 9d35547..2f5d7fb 100644 --- a/roles/install_openvpn/tasks/main.yml +++ b/roles/install_openvpn/tasks/main.yml @@ -8,32 +8,38 @@ copy: src: ca.crt dest: /etc/openvpn/client/ca.crt + notify: restart openvpn - name: install crl.pem copy: src: crl.pem dest: /etc/openvpn/client/crl.pem + notify: restart openvpn - name: install mullvad-up.sh copy: src: mullvad-up.sh dest: /etc/openvpn/client/mullvad-up.sh mode: 0744 + notify: restart openvpn - name: install mullvad.conf template: src: mullvad.conf.j2 dest: /etc/openvpn/client/mullvad.conf + notify: restart openvpn - name: install mullvad.key template: src: mullvad.key.j2 dest: /etc/openvpn/client/mullvad.key + notify: restart openvpn - name: install mullvad.crt template: src: mullvad.crt.j2 dest: /etc/openvpn/client/mullvad.crt + notify: restart openvpn - name: create sysetmd openvpn folder file: -- cgit v1.2.3-54-g00ecf