05:52
This commit is contained in:
@@ -146,7 +146,7 @@
|
||||
{{
|
||||
dict(
|
||||
nb_tokens
|
||||
| select('match', '^[a-zA-Z_]+=')
|
||||
| select('match', '^[a-zA-Z_]+=')
|
||||
| map('split', '=', 1)
|
||||
| map('list')
|
||||
)
|
||||
@@ -429,6 +429,71 @@
|
||||
payload_encoding: "string"
|
||||
changed_when: false
|
||||
|
||||
# ----------------------- Dev1 wifidebug.sh check & publish -----------------------
|
||||
- name: Dev1 | Check wifidebug.sh presence
|
||||
delegate_to: localhost
|
||||
shell: |
|
||||
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
|
||||
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
|
||||
"test -f /root/wifidebug.sh && echo present || echo missing"
|
||||
register: wd_present
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Dev1 | Set presence fact
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
wifidebug_present: "{{ (wd_present.stdout | default('') | trim) == 'present' }}"
|
||||
|
||||
- name: Dev1 | Read wifidebug.sh version (SCRIPTVERSION)
|
||||
when: wifidebug_present | default(false)
|
||||
delegate_to: localhost
|
||||
shell: |
|
||||
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
|
||||
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
|
||||
"grep -m1 'SCRIPTVERSION' /root/wifidebug.sh 2>/dev/null | awk -F'=' '{print \$2}' | tr -d '[:space:]' | sed -E 's/^v?([0-9].*)$/\1/'"
|
||||
register: wd_version_raw
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Dev1 | Normalize wifidebug version
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
wd_version_clean: "{{ wd_version_raw.stdout | default('') | trim }}"
|
||||
|
||||
- name: Dev1 | Compute wifidebug value
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
wifidebug_value: >-
|
||||
{%- if not (wifidebug_present | default(false)) -%}missing
|
||||
{%- elif (wd_version_clean | default('') | length) > 0 -%}v{{ wd_version_clean }}
|
||||
{%- else -%}n/a{%- endif -%}
|
||||
|
||||
- name: Publish Dev1 wifidebug 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': 'wifidebug',
|
||||
'task_result': wifidebug_value
|
||||
} | to_json }}"
|
||||
payload_encoding: "string"
|
||||
changed_when: false
|
||||
|
||||
# ----------------------- Dev2 auth + firmux -----------------------
|
||||
- name: Try DEV2 login
|
||||
when: tunnel_ok|default(false)
|
||||
|
||||
Reference in New Issue
Block a user