Is it possible to auto generate the vm10,vm11,vm12 in the below script (as count.index used in terraform) ? I would like to pass/define name "vm" and should be able to deploy 3 vm's with the different names vm10, vm11 and vm12. Please suggest a way, Thanks
---
- hosts: Target
vars:
machines:
v10:
mem: 1024
vcpu: 1
v11:
mem: 1024
vcpu: 1
tasks:
- name: img cpy
copy:
src: /root/pri.qcow2
dest: /test/{{ item.key }}.qcow2
remote_src: yes
with_dict: "{{ machines }}"
- name: Import/Load VM
command: >
virt-install --name {{ item.key }} --memory {{ item.value.mem }} --vcpus {{ item.value.vcpu }} --disk /test/{{ item.key }}.qcow2,bus=sata --import --os-variant generic --network default --noreboot
with_dict: "{{ machines }}"