From 668af8bdb6b21f3c77a0e287af35c6927c76da77 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 19 May 2024 10:09:37 +0200 Subject: [PATCH] firewall: use a handler to reboot --- roles/firewall/handlers/main.yml | 4 ++++ roles/firewall/tasks/mgmt.yml | 18 ++++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/roles/firewall/handlers/main.yml b/roles/firewall/handlers/main.yml index 46bf0d7..d2beb3b 100644 --- a/roles/firewall/handlers/main.yml +++ b/roles/firewall/handlers/main.yml @@ -6,6 +6,10 @@ command: mkinitfs when: "'handler' not in ansible_skip_tags" +- name: reboot + reboot: + when: "'handler' not in ansible_skip_tags" + - name: reload frr command: /usr/lib/frr/frr-reload.py --reload /etc/frr/frr.conf when: "'handler' not in ansible_skip_tags" diff --git a/roles/firewall/tasks/mgmt.yml b/roles/firewall/tasks/mgmt.yml index bddee5e..8b5b976 100644 --- a/roles/firewall/tasks/mgmt.yml +++ b/roles/firewall/tasks/mgmt.yml @@ -3,23 +3,13 @@ dest: /etc/network/interfaces.d/mgmt.intf src: mgmt.intf.j2 mode: 0644 - register: task_mgmt_interface + notify: reboot - name: Run SSH in management VRF lineinfile: path: /etc/conf.d/sshd + regexp: "#* *vrf=" line: "vrf=\"mgmt\"" - register: task_ssh_vrf + notify: reboot -- name: Reboot for new VRF - reboot: - when: task_mgmt_interface.changed or task_ssh_vrf.changed - register: task_reboot - -- name: Reset the connection - meta: reset_connection - -- name: Wait for the network device to reload - wait_for_connection: - delay: 10 - when: task_reboot.changed +- meta: flush_handlers