Files
ansible-worker/files/ansible-playbooks/sot-updater-wrapper.yml
2026-01-20 06:37:11 +02:00

50 lines
1.5 KiB
YAML

# sot-updater-wrapper.yml
# Single nbplay invocation:
# Phase 1: Cloud -> NetBox sync (via sot-updater-iponly.yml in wrapper mode)
# Phase 2: Refresh ansible_host from nb_ip, reset_connection
# Phase 3: Run full sot-updater-current.yml
- import_playbook: sot-updater-iponly.yml
vars:
sot_wrapper_mode: true
- name: Phase 2 | Refresh in-memory target IP after iponly
hosts: all
gather_facts: no
- debug:
msg:
- "host nb_ok={{ nb_ok | default('UNDEF') }}, nb_ip={{ nb_ip | default('UNDEF') }}"
- "localhost nb_ok={{ hostvars['localhost'].nb_ok | default('UNDEF') }}, nb_ip={{ hostvars['localhost'].nb_ip | default('UNDEF') }}"
tasks:
- name: "Wrapper | Assert iponly succeeded"
ansible.builtin.assert:
that:
- nb_script is defined
- nb_script.stat.exists | default(false)
- nb_ok | default(false)
- (nb_ip | default('') | trim) not in ('', 'NONE', 'null')
fail_msg: >-
Wrapper stop: iponly did not produce a usable IP.
nb_ok={{ nb_ok | default('UNDEF') }},
nb_ip='{{ nb_ip | default('UNDEF') }}'
- name: "Wrapper | Override ansible_host to refreshed IP ({{ nb_ip }})"
set_fact:
ansible_host: "{{ nb_ip | trim }}"
- name: "Wrapper | Reset SSH connection context (ensure new ansible_host is used)"
meta: reset_connection
- name: "Wrapper | Debug effective target"
debug:
msg:
- "Effective ansible_host={{ ansible_host }}"
- "nb_ip={{ nb_ip }}"
- import_playbook: sot-updater.yml