# Ping module status in CSV

**URL:** <https://forum.ansible.com/t/ping-module-status-in-csv/30142>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 18, 2019, 5:15am UTC](https://forum.ansible.com/t/ping-module-status-in-csv/30142 "2019-04-18T05:15:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vandyy\_Vines](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@The\_Vandyy\_Vines](https://forum.ansible.com/u/The_Vandyy_Vines)\
**Post date:** [April 18, 2019, 5:15am UTC](https://forum.ansible.com/t/ping-module-status-in-csv/30142/1 "2019-04-18T05:15:13Z")

</div>

Hello Team,

I have created a csv for gathered facts of linux and windows targets.

Now i am trying to add a column with Ping module status and result code if it fails.  
I wrote this play in the role- this is for linux targets :

---

<div class="post-metadata">

**Author:** ![S\_C\_Rigler](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@S\_C\_Rigler](https://forum.ansible.com/u/S_C_Rigler)\
**Post date:** [April 18, 2019, 1:13pm UTC](https://forum.ansible.com/t/ping-module-status-in-csv/30142/2 "2019-04-18T13:13:11Z")

</div>

Maybe use the value of “ping\_res.rc”. It’s the return code of the command; so it would be “0” for success.

Eg:

{{ (ping\_res.rc|int == 0) | ternary(‘UP’, ‘DOWN’) }}

–Steve

---

<div class="post-metadata">

**Author:** ![The\_Vandyy\_Vines](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@The\_Vandyy\_Vines](https://forum.ansible.com/u/The_Vandyy_Vines)\
**Post date:** [April 18, 2019, 4:13pm UTC](https://forum.ansible.com/t/ping-module-status-in-csv/30142/3 "2019-04-18T16:13:19Z")

</div>

Thanks , but how can i register this status simultaneously, since i need to call that status in csv .

Also can i grep a specifuc string from ping module output n then define a customised result code and set that result code value in csv ?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![The\_Vandyy\_Vines](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@The\_Vandyy\_Vines](https://forum.ansible.com/u/The_Vandyy_Vines)\
**Post date:** [April 22, 2019, 10:07am UTC](https://forum.ansible.com/t/ping-module-status-in-csv/30142/4 "2019-04-22T10:07:29Z")

</div>

Further, to customize this.  
I now have the ping module output for target hosts.  
Now haw can i decide result code in the ping output.

Like eg, if A(some string) is present in the ping output then Register RC = x

if B(some string) is present in the ping output then Register RC =y

these registered values to be called in the above csv .

I tried ternary expressions(as suggested) but i don’t know how to fetch the above condition .

Thanks for the help.

BR//  
Vandana
