Ping module status in CSV

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 :

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

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 :slight_smile:

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