On Fri, 26 May 2023 at 19:40, Joefrey Kimmel <
joefrey...@gmail.com> wrote:
>
> Correct. The control node is an Ansible Tower server that we have limited access to.
That indeed does not leave much.
I'm not sure but the problem may be that you're using the quoted json
style to define your list of key/values.
If I lay that out as basic yaml (same data structure, but a bit
cleaner to look at), it does seem to work for me:
---
- name: xml slurp and filter
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Create dictionary of values from test.xml
ansible.builtin.set_fact:
file_xml_data: '{{ file_xml_data | default({}) |
combine({item.key: item.value}) }}'
loop:
- key: cifs_share
value: "{{ file_xml | regex_search('<SharedPath>(.+)</',
'\\1') | first }}"
- debug:
var: file_xml_data
vars:
file_xml: |
</ClusterParameters>
gives:
dick.visser@GA0267 ~$ ansible-playbook work/tasks/xml4.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
PLAY [filter] ******************************************************************
TASK [Create dictionary of values from test.xml] *******************************
ok: [localhost] => (item={'key': 'cifs_share', 'value':
'\\\\
somewhere.com\\adata\\aclusters\\bytes'})
TASK [debug] *******************************************************************
ok: [localhost] =>
file_xml_data:
cifs_share: \\
somewhere.com\adata\aclusters\bytes
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0
failed=0 skipped=0 rescued=0 ignored=0
Still, DIY string parsing of XML is never bullet proof. What happens
if things span multiple lines, etc etc.
In short, YMMV.