This commit is contained in:
2026-01-14 05:05:58 +02:00
parent de398ee498
commit 776bc44bf8

View File

@@ -455,76 +455,35 @@
payload_encoding: "string"
changed_when: false
# ----------------------- Dev1 SSID count (strict then fallback) -----------------------
- name: Dev1 | Count SSID lines (strict 'ssid' + 'ikeja')
# ----------------------- Dev1 SSID count (jq-based, schema-aware) -----------------------
- name: Dev1 | SSID profiles summary via jq (AP radios only)
delegate_to: localhost
shell: |
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"cat /tmp/config.json 2>/dev/null | grep ssid | grep ikeja | wc -l"
register: ssid_strict_count_raw
"jq -r '
.wireless.radios
| to_entries[]
| select(.value.mode == \"ap\")
| (.value.vaps // [])
| map(select(has(\"ssid\")))
| map({ssid:.ssid, enabled:(.enabled // false)})
| unique_by(.ssid, .enabled)
| {
e: (map(select(.enabled==true)) | length),
d: (map(select(.enabled==false)) | length)
}
| \"\\(.e + .d) (\\(.e)e \\(.d)d)\"
' /tmp/config.json 2>/dev/null || echo '0 (0e 0d)'"
register: ssid_profiles_summary_raw
changed_when: false
failed_when: false
ignore_errors: true
- name: Dev1 | Normalize strict SSID count
- name: Dev1 | Normalize SSID profiles summary
delegate_to: localhost
set_fact:
ssid_strict_count: "{{ (ssid_strict_count_raw.stdout | default('0')) | trim }}"
- name: Dev1 | Decide if strict count usable
delegate_to: localhost
set_fact:
ssid_strict_ok: >-
{{
(ssid_strict_count | int) > 0
and ((ssid_strict_count | int) % 2 == 0)
}}
- name: Dev1 | Count SSID lines (fallback exclude bssid/auto_ssid/SC/backhaul)
when: not ssid_strict_ok | default(false)
delegate_to: localhost
shell: |
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"cat /tmp/config.json 2>/dev/null | grep ssid | grep -vE 'bssid|auto_ssid|SC|backhaul' | wc -l"
register: ssid_fallback_count_raw
changed_when: false
failed_when: false
ignore_errors: true
- name: Dev1 | Normalize fallback SSID count
when: not ssid_strict_ok | default(false)
delegate_to: localhost
set_fact:
ssid_fallback_count: "{{ (ssid_fallback_count_raw.stdout | default('0')) | trim }}"
- name: Dev1 | Compute final SSID count
delegate_to: localhost
set_fact:
ssid_final_count: >-
{{
(ssid_strict_ok | default(false))
| ternary(
(ssid_strict_count | default('0') | int) // 2,
(ssid_fallback_count | default('0') | int) // 2
)
}}
- name: Dev1 | SSID counting debug
delegate_to: localhost
debug:
msg:
- "ssid_strict_ok={{ ssid_strict_ok | default(false) }}"
- "ssid_strict_count={{ ssid_strict_count | default('n/a') }}"
- "ssid_fallback_count={{ ssid_fallback_count | default('n/a') }}"
- "ssid_final_count={{ ssid_final_count | default('n/a') }}"
- name: Dev1 | Build multissidfix value
delegate_to: localhost
when: ssid_final_count is defined
set_fact:
multissidfix_value: "{{ (ssid_final_count | int) ~ ' ssids' }}"
multissidfix_value: "{{ (ssid_profiles_summary_raw.stdout | default('0 (0e 0d)')) | trim }}"
- name: Dev1 | multissidfix debug
delegate_to: localhost