0522
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
# restart-cloud-agent-wrapper.yml
|
# restart-cloud-agent-wrapper.yml
|
||||||
# Single nbplay invocation:
|
# Phase 1: Subsystem -> NetBox sync for current inventory_hostname
|
||||||
# Phase 1: Subsystem -> NetBox IP sync (via netbox_subsystem_ikejanum_recursive.py)
|
# Phase 2: Restart cloud-agent on the device
|
||||||
# Phase 2: Restart cloud-agent on the device (via restart-cloud-agent.yml)
|
|
||||||
|
|
||||||
- name: Phase 1 | Subsystem -> NetBox sync before cloud-agent restart
|
- name: Phase 1 | Subsystem -> NetBox sync before cloud-agent restart
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Wait 20s before restoring
|
- name: Wait 20s before restoring
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
@@ -21,12 +19,12 @@
|
|||||||
|
|
||||||
- name: "Wrapper | Run netbox_subsystem_ikejanum_recursive.py for {{ inventory_hostname }}"
|
- name: "Wrapper | Run netbox_subsystem_ikejanum_recursive.py for {{ inventory_hostname }}"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.command:
|
ansible.builtin.shell: |
|
||||||
argv:
|
set -o pipefail
|
||||||
- python3
|
python3 -u ./netbox_subsystem_ikejanum_recursive.py "{{ inventory_hostname }}" 2>&1
|
||||||
- ./netbox_subsystem_ikejanum_recursive.py
|
args:
|
||||||
- "{{ inventory_hostname }}"
|
executable: /bin/bash
|
||||||
register: subsystem_preflight
|
register: subsystem_sync
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
when: subsystem_script.stat.exists | default(false)
|
when: subsystem_script.stat.exists | default(false)
|
||||||
@@ -36,9 +34,15 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg:
|
msg:
|
||||||
- "script_exists={{ subsystem_script.stat.exists | default(false) }}"
|
- "script_exists={{ subsystem_script.stat.exists | default(false) }}"
|
||||||
- "rc={{ subsystem_preflight.rc | default('NA') }}"
|
- "rc={{ subsystem_sync.rc | default('NA') }}"
|
||||||
- "stdout_lines={{ subsystem_preflight.stdout_lines | default([]) }}"
|
- "stdout_lines={{ subsystem_sync.stdout_lines | default([]) }}"
|
||||||
- "stderr_lines={{ subsystem_preflight.stderr_lines | default([]) }}"
|
- "stderr_lines={{ subsystem_sync.stderr_lines | default([]) }}"
|
||||||
changed_when: false
|
- "raw stdout (joined): {{ subsystem_sync.stdout | default('') }}"
|
||||||
|
- "raw stderr (joined): {{ subsystem_sync.stderr | default('') }}"
|
||||||
|
when: subsystem_script.stat.exists | default(false)
|
||||||
|
|
||||||
|
- name: "Wrapper | Abort softly if script missing"
|
||||||
|
ansible.builtin.meta: end_host
|
||||||
|
when: not (subsystem_script.stat.exists | default(false))
|
||||||
|
|
||||||
- import_playbook: restart-cloud-agent.yml
|
- import_playbook: restart-cloud-agent.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user