# When condition and fetching values

**URL:** <https://forum.ansible.com/t/when-condition-and-fetching-values/30499>\
**Category:** Ansible Project\
**Created:** [June 5, 2019, 8:28pm UTC](https://forum.ansible.com/t/when-condition-and-fetching-values/30499 "2019-06-05T20:28:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanisha\_Mishra](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tanisha\_Mishra](https://forum.ansible.com/u/Tanisha_Mishra)\
**Post date:** [June 5, 2019, 8:28pm UTC](https://forum.ansible.com/t/when-condition-and-fetching-values/30499/1 "2019-06-05T20:28:52Z")

</div>

I am using csv python module for importing a csv file  
The csv is importing but unable to fetch the values properly.  
My main aim is the prompt that takes as server name needs to check from the csv list whether it exists or not…  
I have to add ‘when’ condition also, but unable to separate HOST\_NAME from actual hostname(s)…  
I need help for ‘when’ condition and ‘looping’ of csv contents…

---

<div class="post-metadata">

**Author:** ![Tanisha\_Mishra](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tanisha\_Mishra](https://forum.ansible.com/u/Tanisha_Mishra)\
**Post date:** [June 5, 2019, 8:36pm UTC](https://forum.ansible.com/t/when-condition-and-fetching-values/30499/2 "2019-06-05T20:36:45Z")

</div>

Please dont suggest ‘lookup’ and default ansible modules.

---

<div class="post-metadata">

**Author:** ![Indian\_Velumani1](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@Indian\_Velumani1](https://forum.ansible.com/u/Indian_Velumani1)\
**Post date:** [June 6, 2019, 1:29pm UTC](https://forum.ansible.com/t/when-condition-and-fetching-values/30499/3 "2019-06-06T13:29:13Z")

</div>

Hi Tanisha,

Check this one may helpful.

File: DBA\_Total\_server\_list\_modified.csv

HOST\_NAME  
zch89vsoedb106  
TX11FPSDB01V  
TX11FPSDB02V  
tx11fpsdb99v
