Adding to Todd's request for more details .. also look at json_query vs selectattr if you are just filtering a JSON list on attribute value.
Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 14, 2023, at 6:50 AM, Todd Lewis <uto...@gmail.com> wrote: Please show us "group_info" and "vm_name": - name: Show registered var group_info and vm_name ansible.builtin.debug: msg: - "group_info: {{ group_info }}" - "vm_name: {{ vm_name }}" It would be helpful to include the job log for the relevant section of your playbook as well. You say you are trying to parse "the list variable" but you don't say what that variable is or show what it contains. Please help us help you. On 7/14/23 3:17 AM, Deepak B K wrote: Hi Groups , I am trying to parse the list variable but I am getting ansible unsafe text I need to match the vm name and get the corresponding vm group from the registered variable vm_groups. tasks: - name: "Gather DRS info about given Cluster" community.vmware.vmware_drs_group_info: hostname: "{{ vcenter.hostname }}" username: "{{ vcenter.username }}" password: "{{ vcenter.password }}" validate_certs: "{{ vcenter.validate_certs }}" cluster_name: "{{ vcenter_env.cluster }}" delegate_to: localhost register: group_info - name: set fact specific group_info VM groups ansible.builtin.set_fact: match_vm_group: "{{ item.drs_group_info[vcenter_env.cluster] | regex_search(vm_name) }}" when: "{{ item.drs_group_info[vcenter_env.cluster] | regex_search( vm_name ) }}" loop: "{{ group_info }}" name: set fact specific VM group ansible.builtin.set_fact: vm_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] | selectattr('type', '==', "vm" ) | list }}” "vm_groups": "“[{'group_name': VM2-on-dev', 'vms': ['deep-test', 'NED-DEV601-X'], 'type': 'vm'}, {'group_name': 'VM2-on-uat', 'vms': ['NED-TST601-X'], 'type': 'vm'} } I appreciate your quick help . Thanks Deepak -- 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 ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/08b16ee1-1087-4b0a-21f7-be65df5dc199%40gmail.com<https://groups.google.com/d/msgid/ansible-project/08b16ee1-1087-4b0a-21f7-be65df5dc199%40gmail.com?utm_medium=email&utm_source=footer>. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CE7B2EAC-2D67-4223-BC7D-61AB8B2E3B83%40nist.gov.