Hi Team,
I am trying to loop with a condition to match vm_name for all the VM
groups I see that the loop stops at the first instance match . I need help
how can I run the loop for all the vm group name in the variable output
to match vm_name and extract the match group names in the list
for example:
"vm_drs_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'}, {'group_name': VM2-on-qa', 'vms':
['deep-test', 'NED-DEV601-X'], 'type': 'vm'}
}
If vm_name = 'NED-DEV601-X' I have two match group name but my logic
stops after the first match how can I search for all the groups in the
register variable.
- name: set fact specific VM group
ansible.builtin.set_fact:
vm_drs_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] |
selectattr('type', '==', "vm" ) | list }}”
- name: "Set facts to specific VM groups for matching vm name"
ansible.builtin.set_fact:
match_vm_group: "{{ item.group_name }}"
when: item | regex_search(vm_name)
loop: "{{ vm_drs_groups }}"
I appreciate any help.
Thanks and Regards,
Deepak Kumar
--
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/8d222b8f-10bf-481f-9d3c-4cb4b91dacd3n%40googlegroups.com.