# Using group vars and vars from vars prompt

**URL:** <https://forum.ansible.com/t/using-group-vars-and-vars-from-vars-prompt/33608>\
**Category:** Ansible Developer\
**Created:** [August 13, 2020, 6:00pm UTC](https://forum.ansible.com/t/using-group-vars-and-vars-from-vars-prompt/33608 "2020-08-13T18:00:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarvani\_Vadali](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@Sarvani\_Vadali](https://forum.ansible.com/u/Sarvani_Vadali)\
**Post date:** [August 13, 2020, 6:00pm UTC](https://forum.ansible.com/t/using-group-vars-and-vars-from-vars-prompt/33608/1 "2020-08-13T18:00:10Z")

</div>

I am trying to get a value through vars prompt in my playbook and writing a task in a role to see if the value == foo or if value == bar  
if the value == foo ,i want to get values from the vars.yaml file which has a section for foo .  
The section for foo in vars.yaml file has source path and destination path for copying.

I am struggling to see how to use loops in this case,any help is appreciated.

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [August 24, 2020, 6:04am UTC](https://forum.ansible.com/t/using-group-vars-and-vars-from-vars-prompt/33608/2 "2020-08-24T06:04:04Z")

</div>

Can you try something like this

- name: Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2)  
&nbsp;&nbsp;include\_vars:  
&nbsp;&nbsp;&nbsp;&nbsp;file: contingency\_plan.yaml  
&nbsp;&nbsp;&nbsp;&nbsp;name: plans  
&nbsp;&nbsp;when: x == 0
