> > On Jan 10, 2024, at 12:16 PM, Vladimir Botka <[email protected]> wrote: > > FWIW, convert the string to a list > > > > s: "['/First Datacenter/vm/Prod-SRM']" > > l: "{{ s|from_yaml }}"
On Fri, 12 Jan 2024 09:05:16 -0800 (PST) Dimitri Yioulos <[email protected]> wrote: > how is that actually written in the playbook? For example, shell> cat pb1.yml - hosts: all vars: s: "['/First Datacenter/vm/Prod-SRM']" l: "{{ s|from_yaml }}" tasks: - debug: var: l|type_debug - debug: var: l.0 gives (abridged) l|type_debug: list l.0: /First Datacenter/vm/Prod-SRM But, the code in your first email shows you get *vm_facts* as registered output of *community.vmware.vmware_guest_find*. Take a look at the Return Values of this module https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_find_module.html#return-values The documentation says *folders* is "list/elements=string". In this case, no conversion is needed to get the element of the list. For example, shell> cat pb2.yml - hosts: all vars: vm_facts: folders: ['/First Datacenter/vm/Prod-SRM'] tasks: - debug: var: vm_facts.folders|type_debug - debug: var: vm_facts.folders.0 gives (abridged) vm_facts.folders|type_debug: list vm_facts.folders.0: /First Datacenter/vm/Prod-SRM FWIW, try community.general.yaml callback. YAML is much easier to read compared to JSON. See https://docs.ansible.com/ansible/latest/collections/community/general/yaml_callback.html -- Vladimir Botka -- 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/20240112212031.226fcc47%40gmail.com.
pgp6fmFkZQx4i.pgp
Description: OpenPGP digital signature
