09:43
This commit is contained in:
@@ -38,34 +38,56 @@
|
|||||||
control_queue: "{{ lookup('env','CONTROLQUEUE') | default('queue_controls', true) }}"
|
control_queue: "{{ lookup('env','CONTROLQUEUE') | default('queue_controls', true) }}"
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: "NB preflight | Run netbox_one_device.py for {{ inventory_hostname }} (chatty)"
|
- name: "NB preflight | Verify script exists"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
environment:
|
ansible.builtin.stat:
|
||||||
PYTHONUNBUFFERED: "1" # make Python flush immediately
|
path: "/opt/containers/ansible-worker/app/nb_onedevice_update.py"
|
||||||
args:
|
register: nb_script
|
||||||
chdir: "/opt/containers/ansible-worker/app"
|
|
||||||
shell: |
|
|
||||||
set -o pipefail
|
|
||||||
python3 netbox_one_device.py "{{ inventory_hostname }}" --chatty 2>&1
|
|
||||||
register: nb_preflight
|
|
||||||
changed_when: false # informational only
|
|
||||||
failed_when: false # soft-fail, keep going
|
|
||||||
|
|
||||||
- name: "NB preflight | Print chatty output"
|
- name: "NB preflight | Abort softly if script missing (path typo?)"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: >-
|
msg:
|
||||||
{{
|
- "NB preflight skipped: /opt/containers/ansible-worker/app/nb_onedevice_update.py not found."
|
||||||
(nb_preflight.stdout_lines | default([])) |
|
- "Tip: adjust chdir/path or script name."
|
||||||
map('regex_replace', '^(.*)$', 'NB | \\1') |
|
when: not nb_script.stat.exists
|
||||||
list
|
|
||||||
}}
|
- name: "NB preflight | Run nb_onedevice_update.py for {{ inventory_hostname }} (chatty)"
|
||||||
|
when: nb_script.stat.exists
|
||||||
|
delegate_to: localhost
|
||||||
|
environment:
|
||||||
|
PYTHONUNBUFFERED: "1" # flush prints immediately
|
||||||
|
# Add any env your script needs here, e.g.:
|
||||||
|
# NB_URL: "{{ lookup('env','NB_URL') | default('', true) }}"
|
||||||
|
# NB_TOKEN: "{{ lookup('env','NB_TOKEN') | default('', true) }}"
|
||||||
|
args:
|
||||||
|
chdir: "/opt/containers/ansible-worker/app"
|
||||||
|
executable: /bin/bash
|
||||||
|
shell: |
|
||||||
|
set -o pipefail
|
||||||
|
python3 -u nb_onedevice_update.py "{{ inventory_hostname }}" --chatty 2>&1
|
||||||
|
register: nb_preflight
|
||||||
|
changed_when: false # informational
|
||||||
|
failed_when: false # soft-fail, keep going
|
||||||
|
|
||||||
|
- name: "NB preflight | Show results"
|
||||||
|
when: nb_script.stat.exists
|
||||||
|
delegate_to: localhost
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg:
|
||||||
|
- "rc={{ nb_preflight.rc }}"
|
||||||
|
- "stdout_lines:"
|
||||||
|
- "{{ (nb_preflight.stdout_lines | default(['<no stdout>'])) }}"
|
||||||
|
- "stderr_lines:"
|
||||||
|
- "{{ (nb_preflight.stderr_lines | default(['<no stderr>'])) }}"
|
||||||
|
- "raw stdout (joined): {{ nb_preflight.stdout | default('') | trim }}"
|
||||||
|
|
||||||
- name: "NB preflight | Pause 1s"
|
- name: "NB preflight | Pause 1s"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
seconds: 1
|
seconds: 1
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: "⚙️ Start | Dev1 banner → tunnel/auth → Dev2 firmux (telemetry mode)"
|
- name: "⚙️ Start | Dev1 banner → tunnel/auth → Dev2 firmux (telemetry mode)"
|
||||||
debug:
|
debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user