From b4ba4a458e05df6a29907dad31418778ba8d4a78 Mon Sep 17 00:00:00 2001 From: pavel Date: Thu, 23 Apr 2026 05:14:54 +0300 Subject: [PATCH] 0514 --- .../restart-cloud-agent-wrapper.yml | 44 +++++++++++++++++++ files/netbox_subsystem_ikejanum_recursive.py | 0 2 files changed, 44 insertions(+) create mode 100644 files/ansible-playbooks/restart-cloud-agent-wrapper.yml create mode 100644 files/netbox_subsystem_ikejanum_recursive.py diff --git a/files/ansible-playbooks/restart-cloud-agent-wrapper.yml b/files/ansible-playbooks/restart-cloud-agent-wrapper.yml new file mode 100644 index 0000000..d17e90c --- /dev/null +++ b/files/ansible-playbooks/restart-cloud-agent-wrapper.yml @@ -0,0 +1,44 @@ +# restart-cloud-agent-wrapper.yml +# Single nbplay invocation: +# Phase 1: Subsystem -> NetBox IP sync (via netbox_subsystem_ikejanum_recursive.py) +# Phase 2: Restart cloud-agent on the device (via restart-cloud-agent.yml) + +- name: Phase 1 | Subsystem -> NetBox sync before cloud-agent restart + hosts: all + gather_facts: no + + tasks: + - name: Wait 20s before restoring + ansible.builtin.pause: + seconds: 20 + + - name: "Wrapper | Verify netbox_subsystem_ikejanum_recursive.py exists" + delegate_to: localhost + ansible.builtin.stat: + path: ./netbox_subsystem_ikejanum_recursive.py + register: subsystem_script + changed_when: false + + - name: "Wrapper | Run netbox_subsystem_ikejanum_recursive.py for {{ inventory_hostname }}" + delegate_to: localhost + ansible.builtin.command: + argv: + - python3 + - ./netbox_subsystem_ikejanum_recursive.py + - "{{ inventory_hostname }}" + register: subsystem_preflight + changed_when: false + failed_when: false + when: subsystem_script.stat.exists | default(false) + + - name: "Wrapper | Show subsystem sync result" + delegate_to: localhost + ansible.builtin.debug: + msg: + - "script_exists={{ subsystem_script.stat.exists | default(false) }}" + - "rc={{ subsystem_preflight.rc | default('NA') }}" + - "stdout_lines={{ subsystem_preflight.stdout_lines | default([]) }}" + - "stderr_lines={{ subsystem_preflight.stderr_lines | default([]) }}" + changed_when: false + +- import_playbook: restart-cloud-agent.yml diff --git a/files/netbox_subsystem_ikejanum_recursive.py b/files/netbox_subsystem_ikejanum_recursive.py new file mode 100644 index 0000000..e69de29