I need a playbook to delete some vm's from VMWare using ANSIBLE
My playbook is similar to:
- name: Delete VMs from VMware
vmware_guest:
hostname: "{{secret.vcenter}}"
username: "{{secret.username}}"
password: "{{secret.password}}"
validate_certs: False
datacenter: DC
state: absent
name: "{{ item.name }}"
with_items:
- { name: VM_NAME_01_GROUP01 }
- { name: VM_NAME_02_GROUP01 }
- { name: VM_NAME_03_GROUP01 }
- { name: VM_NAME_04_GROUP01 }
It works well, the problem is that I have 18 GROUPs and I wouldn't like to write 4x18=78 lines to do this
other machine names:
[...]
VM_NAME_01_GROUP04
VM_NAME_02_GROUP04
VM_NAME_03_GROUP04
VM_NAME_04_GROUP04
[...]
VM_NAME_01_GROUP18
VM_NAME_02_GROUP18
VM_NAME_03_GROUP18
VM_NAME_04_GROUP18
I need a king of loop...
Thanks in advice.