On Fri, 26 May 2023 at 19:40, Joefrey Kimmel <[email protected]> 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: |
      <?xml version="1.0" encoding="utf-8"?>
      <ClusterParameters xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
        <SharedPath>\\somewhere.com\adata\aclusters\bytes</SharedPath>
      </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.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLY3xX9CFPJYBRk_-Bj6fFj0H6hnQU07Q7L8h1AfhuPT5g%40mail.gmail.com.

Reply via email to