Skip to content

Commit

Permalink
issue #49 : alias - fix multivalue list for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Dec 15, 2023
1 parent 0d49ceb commit faeba0a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tasks/aliasmultivalue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
register: _configured_multivalue_alias
ignore_errors: true # do not fail if node not exists

- debug:
var: _configured_multivalue_alias.matches[0][item.1.key].split('\n') | sort
- debug:
var: item.1.list | sort
- name: check if multivalue list is sortable
ansible.builtin.set_fact:
_listsort: "{{ item.1.list | sort }}"
ignore_errors: true
register: _listsortresult

- name: fix multivalue list for sorting
ansible.builtin.set_fact:
_listsort: "[{% for i in item.1.list %}'{{ i }}',{% endfor %}]"
when: _listsortresult.failed | bool

- name: set multivalue alias
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: "/opnsense/OPNsense/Firewall/Alias/aliases/alias[@uuid='{{ item.0.uuid }}']/{{ item.1.key }}"
value: "{{ item.1.list | join('\n') }}"
value: "{{ _listsort | join('\n') }}"
pretty_print: true
when:
- _configured_multivalue_alias.failed | bool or _configured_multivalue_alias.matches[0][item.1.key].split('\n') | sort != item.1.list | sort
- _configured_multivalue_alias.failed | bool or _configured_multivalue_alias.matches[0][item.1.key].split('\n') | sort != _listsort | sort

...

0 comments on commit faeba0a

Please sign in to comment.