This commit is contained in:
2026-01-20 09:42:33 +02:00
parent 56a1abb898
commit 8700d8125a

View File

@@ -534,69 +534,83 @@
when: dev2_conn_final == "tunnel"
delegate_to: localhost
ansible.builtin.shell: |
set -e
PORT="{{ _local_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh {{ ssh_opts_common }} \
-o AddressFamily=inet \
-o ConnectionAttempts=1 \
-p "$PORT" "{{ dev2_ssh_user }}@127.0.0.1" \
"uptime 2>/dev/null || true"
"{{ pathprefix }} uptime 2>&1 || true"
args: { executable: /bin/bash }
register: dev2_uptime
changed_when: false
failed_when: false
- name: DEV2 | uptime debug (tunnel)
when: dev2_conn_final == "tunnel"
delegate_to: localhost
ansible.builtin.debug:
msg:
- "uptime.rc={{ dev2_uptime.rc | default('n/a') }}"
- "uptime.stdout='{{ dev2_uptime.stdout | default('') | regex_replace('\r','') }}'"
- "uptime.stderr='{{ dev2_uptime.stderr | default('') | regex_replace('\r','') }}'"
- name: DEV2 | uptime (direct LLDP IPv4 primary)
when: dev2_conn_final == "direct_lldp"
delegate_to: localhost
ansible.builtin.shell: |
set -e
HOST="{{ lldp_dev2_ip }}"
sshpass -f "{{ dev2_passfile_used }}" ssh {{ ssh_opts_common }} \
-o AddressFamily=inet \
-o ConnectionAttempts=1 \
"{{ dev2_ssh_user }}@${HOST}" \
"uptime 2>/dev/null || true"
"{{ pathprefix }} uptime 2>&1 || true"
args: { executable: /bin/bash }
register: dev2_uptime
changed_when: false
failed_when: false
- name: DEV2 | uptime (LLDP IPv4 fallback)
when: dev2_conn_final == "lldp4_fallback"
delegate_to: localhost
ansible.builtin.shell: |
set -e
HOST="{{ lldp_dev2_ip }}"
sshpass -f "{{ dev2_passfile_used_lldp }}" ssh {{ ssh_opts_common }} \
-o AddressFamily=inet \
-o ConnectionAttempts=1 \
"{{ dev2_ssh_user }}@${HOST}" \
"uptime 2>/dev/null || true"
"{{ pathprefix }} uptime 2>&1 || true"
args: { executable: /bin/bash }
register: dev2_uptime
changed_when: false
failed_when: false
- name: DEV2 | uptime (LLDP IPv6 via DEV1 nested)
when: dev2_conn_final == "lldp6_via_dev1"
delegate_to: localhost
ansible.builtin.shell: |
set -e
IP6="{{ lldp_dev2_ip6 }}"
F="{{ dev2_passfile_used_lldp6 }}"
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
-o ConnectionAttempts=1 \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"sshpass -f '/tmp/${F}' ssh \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \
'{{ dev2_ssh_user }}@\[${IP6}%{{ dev1_iface }}\]' \
'uptime 2>/dev/null || true'"
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \
'{{ dev2_ssh_user }}@\[${IP6}%{{ dev1_iface }}\]' \
'{{ pathprefix }} uptime 2>&1 || true'"
args: { executable: /bin/bash }
register: dev2_uptime
changed_when: false
failed_when: false
- name: Output DEV2 uptime (stdout)
delegate_to: localhost
ansible.builtin.debug:
msg:
- "DEV2 uptime via {{ dev2_conn_final }}:"
- "{{ (dev2_uptime.stdout | default('') | trim) if (dev2_uptime is defined) else '<no output>' }}"
- "{{ (dev2_uptime.stdout | default('') | regex_replace('\r','')) }}"
post_tasks:
- name: Cleanup (always)