# Variable Prompt under a Task

**URL:** <https://forum.ansible.com/t/variable-prompt-under-a-task/26980>\
**Category:** Ansible Project\
**Created:** [March 13, 2018, 9:10am UTC](https://forum.ansible.com/t/variable-prompt-under-a-task/26980 "2018-03-13T09:10:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Dhingra](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mohit\_Dhingra](https://forum.ansible.com/u/Mohit_Dhingra)\
**Post date:** [March 13, 2018, 9:10am UTC](https://forum.ansible.com/t/variable-prompt-under-a-task/26980/1 "2018-03-13T09:10:16Z")

</div>

Hi All,  
I want to get the variable from user. But the definition of the variable prompt has to be in the role.

I am using three actions, Lets say A,B and C. for every action(input from user) different roles will be called. But before calling respective role it should prompt the variable requirement of that role. So can we use variable prompt in a task. or any other solution for the same.

Thanks,  
Mohit

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [March 13, 2018, 10:11am UTC](https://forum.ansible.com/t/variable-prompt-under-a-task/26980/2 "2018-03-13T10:11:18Z")

</div>

Why would not first ask, and than pass choice as an external variable to playbook?

You can ask with native shell support.

---

<div class="post-metadata">

**Author:** ![Mohit\_Dhingra](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mohit\_Dhingra](https://forum.ansible.com/u/Mohit_Dhingra)\
**Post date:** [March 14, 2018, 6:17am UTC](https://forum.ansible.com/t/variable-prompt-under-a-task/26980/3 "2018-03-14T06:17:58Z")

</div>

But if i would first ask, It will ask all the variables that are being used in roles A, B and C. But i want to ask first which role to use and then i want to ask the variables that are being used in selected role.

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [March 14, 2018, 8:58am UTC](https://forum.ansible.com/t/variable-prompt-under-a-task/26980/4 "2018-03-14T08:58:35Z")

</div>

I believe you are over-complicating things, per described.
