From cb671b34744ec879322b3d4cb4a0ac4ebaeab6b7 Mon Sep 17 00:00:00 2001 From: pavel Date: Wed, 26 Nov 2025 22:56:30 +0200 Subject: [PATCH] 2256 --- files/ansible-playbooks/update-indoor4.yml | 43 +++++++++------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/files/ansible-playbooks/update-indoor4.yml b/files/ansible-playbooks/update-indoor4.yml index 860d415..4e098bd 100644 --- a/files/ansible-playbooks/update-indoor4.yml +++ b/files/ansible-playbooks/update-indoor4.yml @@ -128,42 +128,35 @@ - name: Capture LLDP-derived DEV2 IP (if any) ansible.builtin.set_fact: - lldp_dev2_ip: "{{ (dev2_lldp_ip_raw.stdout | default('')) | trim }}" - changed_when: false + lldp_dev2_ip: >- + {{ hostvars[inventory_hostname].lldp_dev2_ip + if (hostvars[inventory_hostname].lldp_dev2_ip is defined) + else (lldp_dev2_ip | default('')) }} - - name: Classify LLDP candidate range - delegate_to: localhost + - name: Classify LLDP candidate via regex (10.x.x.x / other / none) ansible.builtin.set_fact: lldp_ip_class: >- - {% set ip = (lldp_dev2_ip | default('')) %} - {% if ip == '' %}none - {% elif ip.startswith('10.') %}10 - {% elif ip.startswith('192.168.') %}192_168 - {% else %}other{% endif %} - changed_when: false + {% if lldp_dev2_ip is not defined or lldp_dev2_ip | trim == '' %} + none + {% elif lldp_dev2_ip | regex_search('^10\\.') %} + 10 + {% else %} + other + {% endif %} - - name: Debug LLDP candidate and classification (new debug) - when: debugging | bool - delegate_to: localhost + - name: Debug LLDP candidate and classification (regex-based) ansible.builtin.debug: msg: - - "LLDP digits={{ dev2_lldp_digits | default('') }}" + - "LLDP digits={{ lldp_digits | default('') }}" - "LLDP candidate IP={{ lldp_dev2_ip | default('') }}" - - "LLDP class={{ lldp_ip_class | default('none') }}" - - # Decide dev2_conn_method = direct_lldp for 10.x, tunnel otherwise - - name: Set connection method to tunnel by default - delegate_to: localhost - ansible.builtin.set_fact: - dev2_conn_method: "tunnel" - changed_when: false + - "LLDP class={{ lldp_ip_class | default('') }}" - name: Switch to direct LLDP mode for 10.x.x.x - when: lldp_ip_class == "10" - delegate_to: localhost ansible.builtin.set_fact: dev2_conn_method: "direct_lldp" - changed_when: false + when: + - lldp_ip_class | trim == '10' + - name: Debug connection method decision (new debug) when: debugging | bool