fix(opnsense): не падать на first по пустой последовательности при поиске uuid активной подписки
ansible-opnsense / deploy (push) Successful in 11s
ansible-opnsense / deploy (push) Successful in 11s
This commit is contained in:
1 parent
1d0ab4da61
commit
7aef3fe063
1 file changed
+10
-2
@@ -168,9 +168,17 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
xray_active_uuid: "{{ uuid }}"
|
xray_active_uuid: "{{ uuid }}"
|
||||||
vars:
|
vars:
|
||||||
uuid: "{{ (xray_added.results | default([]) | selectattr('item.name', 'equalto', active_name) | map(attribute='json.uuid') | first)
|
# first на пустой последовательности — фатальная ошибка, поэтому list + индекс
|
||||||
or (xray_current.json.rows | default([]) | selectattr('name', 'equalto', active_name) | map(attribute='uuid') | first) }}"
|
|
||||||
active_name: "{{ xray_desired | selectattr('active') | map(attribute='name') | first }}"
|
active_name: "{{ xray_desired | selectattr('active') | map(attribute='name') | first }}"
|
||||||
|
all_uuids: "{{ (xray_added.results | default([]) | selectattr('item.name', 'equalto', active_name) | map(attribute='json.uuid') | list)
|
||||||
|
+ (xray_current.json.rows | default([]) | selectattr('name', 'equalto', active_name) | map(attribute='uuid') | list) }}"
|
||||||
|
uuid: "{{ all_uuids[0] if all_uuids | length > 0 else '' }}"
|
||||||
|
|
||||||
|
- name: Проверить, что активная подписка найдена в OPNsense
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- xray_active_uuid | length > 0
|
||||||
|
fail_msg: "Активная подписка не найдена в OPNsense после синхронизации инстансов."
|
||||||
|
|
||||||
- name: Провалидировать конфиг активной подписки
|
- name: Провалидировать конфиг активной подписки
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
|
|||||||
Reference in new issue
Block a user