# prompt with loop

**URL:** <https://forum.ansible.com/t/prompt-with-loop/31994>\
**Category:** Ansible Project\
**Created:** [January 16, 2020, 4:32pm UTC](https://forum.ansible.com/t/prompt-with-loop/31994 "2020-01-16T16:32:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [January 16, 2020, 4:32pm UTC](https://forum.ansible.com/t/prompt-with-loop/31994/1 "2020-01-16T16:32:28Z")

</div>

I would like that with each creation of vm of my csv file, it asks me for a confirmation o / n which I put in my prompt?

Example:

Would you like to create this vm “vmname” (o / n)? :

I would like him to ask me this question each time I create my vm, so each loop

My tasks is :

vars\_prompt:

- name: “choix\_utilisateur”  
prompt: “Do you want to create the VM ? (o/n) :”  
private: no  
default: “n”

tasks:

- name: read the csv file  
read\_csv:  
path: /root/Projet\_Ansible/roles/files/create\_vm.csv  
delimiter: ‘,’  
register: report\_csv  
delegate\_to: localhost

- name: “Create a virtual machine ESXI”  
vmware\_guest:  
hostname: “172.180.0.133”  
username: “root”  
password: “espoire”  
port: 443  
validate\_certs: no  
folder: “”  
name: “{{ vm.vmname }}”  
datacenter: “{{ vm.datacenter }}”  
state: poweredoff  
guest\_id: centos64Guest

# This is hostname of particular ESXi server on which user wants VM to be deployed

esxi\_hostname: “172.180.0.100”  
disk:

- size\_gb: “{{ vm.sizegb }}”  
type: thin  
datastore: “{{ vm.datastore }}”  
hardware:  
memory\_mb: “{{ vm.memory }}”  
num\_cpus: “{{ vm.numcpu }}”  
scsi: paravirtual  
networks:
- name: VM Network  
device\_type: vmxnet3  
register: deploy\_vm  
delegate\_to: localhost  
loop: “{{ report\_csv.list }}”  
loop\_control:  
loop\_var: vm  
when: choix\_utilisateur == “o” and inventory\_hostname in groups[‘ESXI’]

Someone have any idea please ??

Thanks you very much community ansible !!! 🙂

Best regards,

Karther

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [January 17, 2020, 4:41pm UTC](https://forum.ansible.com/t/prompt-with-loop/31994/2 "2020-01-17T16:41:13Z")

</div>

up !!

Can you help me please !! 🙂

Best Regards,

Karther
