This commit is contained in:
2025-11-07 06:10:23 +02:00
parent 26bf11f8a3
commit f0f30264c0

View File

@@ -380,6 +380,33 @@
set_fact:
tunnel_ok: "{{ nc_probe.rc == 0 }}"
# ----------------------- Fallback hint: LLDP IP debug when tunnel is down -----------------------
- name: Dev1 | Try LLDP-derived Dev2 IP (tunnel unavailable)
when: not (tunnel_ok | default(false))
delegate_to: localhost
shell: |
DIGITS="{{ inventory_hostname | regex_replace('[^0-9]', '') }}"
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"cat /var/run/lldp_server.json 2>/dev/null | grep ${DIGITS} -A 10 | grep address | grep -vE 'subtype|ipv6' | awk -F'\"' '{ print \$4 }' | head -n1"
register: lldp_ip_raw
changed_when: false
failed_when: false
ignore_errors: true
- name: Dev1 | Debug LLDP candidate IP for Dev2
when: not (tunnel_ok | default(false))
delegate_to: localhost
set_fact:
lldp_dev2_ip: "{{ lldp_ip_raw.stdout | default('') | trim }}"
- name: Dev1 | Show LLDP candidate IP (Dev2)
when: not (tunnel_ok | default(false))
delegate_to: localhost
debug:
msg:
- "LLDP-derived Dev2 IP (best-effort): {{ (lldp_dev2_ip | default('') | trim) if (lldp_dev2_ip | default('') | trim | length) > 0 else '<none>' }}"
# ----------------------- Dev1 banner -----------------------
- name: Dev1 | Probe banner
delegate_to: localhost