1044
This commit is contained in:
@@ -742,6 +742,80 @@
|
|||||||
non_ts_diff_found: true
|
non_ts_diff_found: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
# ----------------------- Dev1 auto_ssid config flag → auto_ssid -----------------------
|
||||||
|
- name: Dev1 | Read auto_ssid from config.json
|
||||||
|
delegate_to: localhost
|
||||||
|
shell: |
|
||||||
|
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
|
||||||
|
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
|
||||||
|
"grep -E '\"auto_ssid\":' /tmp/config.json 2>/dev/null | head -n1 | awk -F: '{print \$2}' | tr -d '[:space:],\"' || true"
|
||||||
|
register: auto_ssid_raw
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Dev1 | Normalize auto_ssid value
|
||||||
|
delegate_to: localhost
|
||||||
|
vars:
|
||||||
|
auto_ssid_raw_clean: "{{ auto_ssid_raw.stdout | default('') | trim | lower }}"
|
||||||
|
set_fact:
|
||||||
|
auto_ssid_value: >-
|
||||||
|
{{
|
||||||
|
auto_ssid_raw_clean
|
||||||
|
if auto_ssid_raw_clean in ['true', 'false']
|
||||||
|
else 'n/a'
|
||||||
|
}}
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
# ----------------------- Scan tracking: Dev1 auto_ssid -----------------------
|
||||||
|
- name: Scan tracking | Dev1 auto_ssid outcome
|
||||||
|
delegate_to: localhost
|
||||||
|
set_fact:
|
||||||
|
scan_ok: "{{ scan_ok + (['auto_ssid'] if ((auto_ssid_value | default('n/a')) != 'n/a') else []) }}"
|
||||||
|
scan_fail: "{{ scan_fail + (['auto_ssid=n/a'] if ((auto_ssid_value | default('n/a')) == 'n/a') else []) }}"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Dev1 | auto_ssid debug
|
||||||
|
delegate_to: localhost
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "auto_ssid_raw={{ auto_ssid_raw.stdout | default('') | trim }}"
|
||||||
|
- "auto_ssid_value={{ auto_ssid_value | default('n/a') }}"
|
||||||
|
|
||||||
|
- name: Publish Dev1 auto_ssid custom field
|
||||||
|
when:
|
||||||
|
- (not (nb_baseline_ok | default(false))) or ((auto_ssid_value) != (nb_custom_fields_current.get('auto_ssid')))
|
||||||
|
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': 'auto_ssid',
|
||||||
|
'task_result': auto_ssid_value
|
||||||
|
} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
|
||||||
|
- name: Delta tracking | Mark changed auto_ssid
|
||||||
|
when:
|
||||||
|
- (not (nb_baseline_ok | default(false))) or ((auto_ssid_value) != (nb_custom_fields_current.get('auto_ssid')))
|
||||||
|
delegate_to: localhost
|
||||||
|
set_fact:
|
||||||
|
non_ts_diff_found: true
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
# ----------------------- Dev1 scroll24.sh check & publish -----------------------
|
# ----------------------- Dev1 scroll24.sh check & publish -----------------------
|
||||||
- name: Dev1 | Check scroll24.sh presence
|
- name: Dev1 | Check scroll24.sh presence
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|||||||
Reference in New Issue
Block a user