1345
This commit is contained in:
@@ -1054,6 +1054,103 @@
|
|||||||
payload_encoding: "string"
|
payload_encoding: "string"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
# ----------------------- Dev2 fw_printenv size → indoor_bootvar -----------------------
|
||||||
|
- name: Dev2 | Read fw_printenv size (tunnel)
|
||||||
|
when:
|
||||||
|
- tunnel_ok | default(false)
|
||||||
|
- dev2_passfile_used != 'NONE'
|
||||||
|
delegate_to: localhost
|
||||||
|
shell: |
|
||||||
|
PORT="{{ _local_port }}"
|
||||||
|
sshpass -f "{{ dev2_passfile_used }}" ssh {{ ssh_opts_common }} \
|
||||||
|
-o ConnectTimeout={{ ssh_timeout }} \
|
||||||
|
-p "$PORT" "{{ dev2_ssh_user }}@127.0.0.1" \
|
||||||
|
"fw_printenv 2>/dev/null | wc -l"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
register: dev2_bootenv_wc_tunnel
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Dev2 | Read fw_printenv size (LLDP)
|
||||||
|
when:
|
||||||
|
- tunnel_ok | default(false)
|
||||||
|
- dev2_passfile_used == 'NONE'
|
||||||
|
- lldp_dev2_ip | length > 0
|
||||||
|
- dev2_passfile_used_lldp is defined
|
||||||
|
- dev2_passfile_used_lldp != 'NONE'
|
||||||
|
delegate_to: localhost
|
||||||
|
shell: |
|
||||||
|
sshpass -f "{{ dev2_passfile_used_lldp }}" ssh \
|
||||||
|
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
|
||||||
|
-o ConnectTimeout=15 \
|
||||||
|
"{{ dev2_ssh_user }}@{{ lldp_dev2_ip }}" \
|
||||||
|
"fw_printenv 2>/dev/null | wc -l"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
register: dev2_bootenv_wc_lldp
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Dev2 | Select fw_printenv size output
|
||||||
|
delegate_to: localhost
|
||||||
|
set_fact:
|
||||||
|
indoor_bootvar_raw: >-
|
||||||
|
{{
|
||||||
|
(dev2_bootenv_wc_tunnel.stdout | default('') | trim)
|
||||||
|
if (
|
||||||
|
(dev2_bootenv_wc_tunnel is defined) and
|
||||||
|
((dev2_bootenv_wc_tunnel.rc | default(1)) == 0) and
|
||||||
|
((dev2_bootenv_wc_tunnel.stdout | default('') | trim | length) > 0)
|
||||||
|
)
|
||||||
|
else (
|
||||||
|
(dev2_bootenv_wc_lldp.stdout | default('') | trim)
|
||||||
|
if (
|
||||||
|
(dev2_bootenv_wc_lldp is defined) and
|
||||||
|
((dev2_bootenv_wc_lldp.rc | default(1)) == 0) and
|
||||||
|
((dev2_bootenv_wc_lldp.stdout | default('') | trim | length) > 0)
|
||||||
|
)
|
||||||
|
else ''
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Dev2 | Normalize indoor_bootvar value
|
||||||
|
delegate_to: localhost
|
||||||
|
set_fact:
|
||||||
|
indoor_bootvar_value: >-
|
||||||
|
{{
|
||||||
|
'unavailable'
|
||||||
|
if (indoor_bootvar_raw | default('') | trim) in ['', '0']
|
||||||
|
else (indoor_bootvar_raw | default('') | trim)
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Publish Dev2 indoor_bootvar custom field
|
||||||
|
delegate_to: localhost
|
||||||
|
uri:
|
||||||
|
url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost|urlencode }}/{{ rmq_exchange|urlencode }}/publish"
|
||||||
|
method: POST
|
||||||
|
user: "{{ rmq_user }}"
|
||||||
|
password: "{{ rmq_pass }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
status_code: 200
|
||||||
|
headers: { content-type: "application/json" }
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
properties: { content_type: "application/json" }
|
||||||
|
routing_key: "{{ control_queue }}"
|
||||||
|
payload: "{{ {
|
||||||
|
'inscope_device': (ansible_hostname|default(inventory_hostname)),
|
||||||
|
'task_name': 'custom_field_set',
|
||||||
|
'task_add1': 'indoor_bootvar',
|
||||||
|
'task_result': indoor_bootvar_value
|
||||||
|
} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: "✅ Cleanup start"
|
- name: "✅ Cleanup start"
|
||||||
debug:
|
debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user