Re: [ansible-project] Ping module status in CSV

2019-04-22 Thread Vandana Thakur
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

On Thu, Apr 18, 2019 at 9:43 PM Vandana Thakur  wrote:

> 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 :)
>
> On Thu, 18 Apr 2019 at 18:44, S C Rigler  wrote:
>
>> 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
>>
>> On Thu, Apr 18, 2019 at 12:15 AM Vandana Thakur 
>> wrote:
>>
>>> 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 :
>>>
>>>
>>> ---
>>>
>>> *  - ping:  register: result*
>>>
>>> *- debug: var=hostvars[inventory_hostname].result*
>>>
>>> - setup:
>>>   delegate_facts: True
>>>
>>> - lineinfile:
>>> create: yes
>>> dest: /{{csv_log}}/setup.csv
>>> line: *"Ping,*
>>> Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project"
>>> state: present
>>>   delegate_to: localhost
>>>   delegate_facts: True
>>>
>>> - lineinfile:
>>> create: yes
>>> regexp: "NONEXISTENTLINE"
>>> dest: /{{csv_log}}/setup.csv
>>> line: 
>>> *"{{ping_res.stdout_lines}},*{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}},{{
>>> inventory_hostname }},{{ ansible_architecture }},{{ ansible_distribution
>>> }},{{ ansible_distribution_version }}"
>>> state: present
>>>   delegate_to: localhost
>>>   delegate_facts: True
>>>
>>>
>>> BUT the issue is , it gives all the output like :
>>>
>>> [root@vuhplabspawx001 tasks]#   cat  /tmp/setup.csv
>>>
>>> Ping,Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project
>>>
>>> [u'PING vuhplabspawx001 (172.20.24.188) 56(84) bytes of data.', u'64
>>> bytes from vuhplabspawx001 (172.20.24.188): icmp_seq=1 ttl=64 time=0.039
>>> ms', u'', u'--- vuhplabspawx001 ping statistics ---', u'1 packets
>>> transmitted, 1 received, 0% packet loss, time 0ms', u'rtt min/avg/max/mdev
>>> = 0.039/0.039/0.039/0.000 ms'],
>>>
>>> 172.20.24.188,vuhplabspawx001,x86_64,CentOS,7.2.1511
>>> [root@vuhplabspawx001 tasks]#
>>>
>>>
>>> How can i  sort this description to  only status and  result code  if
>>> it  fails.
>>>
>>> Thanks in advance.:)
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>> To post to this group, send email to ansible-project@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CALJDb0mMwEGMXR3LP1vfOPjumBL9xkdYU9Hy-jRZNq_v%3DvhFMw%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAFbiokcDVo4uFVoq%3DLf%2B%3D8E1r7PhFxCtkSdVvtE8kjA04mTgyQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALJDb0kRuTm9JqpS9R-5ROb5SxSB10YGT0Khs%2BVVorqzP9JT-Q%

Re: [ansible-project] Ping module status in CSV

2019-04-18 Thread Vandana Thakur
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 :)

On Thu, 18 Apr 2019 at 18:44, S C Rigler  wrote:

> 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
>
> On Thu, Apr 18, 2019 at 12:15 AM Vandana Thakur 
> wrote:
>
>> 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 :
>>
>>
>> ---
>>
>> *  - ping:  register: result*
>>
>> *- debug: var=hostvars[inventory_hostname].result*
>>
>> - setup:
>>   delegate_facts: True
>>
>> - lineinfile:
>> create: yes
>> dest: /{{csv_log}}/setup.csv
>> line: *"Ping,*
>> Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project"
>> state: present
>>   delegate_to: localhost
>>   delegate_facts: True
>>
>> - lineinfile:
>> create: yes
>> regexp: "NONEXISTENTLINE"
>> dest: /{{csv_log}}/setup.csv
>> line: 
>> *"{{ping_res.stdout_lines}},*{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}},{{
>> inventory_hostname }},{{ ansible_architecture }},{{ ansible_distribution
>> }},{{ ansible_distribution_version }}"
>> state: present
>>   delegate_to: localhost
>>   delegate_facts: True
>>
>>
>> BUT the issue is , it gives all the output like :
>>
>> [root@vuhplabspawx001 tasks]#   cat  /tmp/setup.csv
>>
>> Ping,Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project
>>
>> [u'PING vuhplabspawx001 (172.20.24.188) 56(84) bytes of data.', u'64
>> bytes from vuhplabspawx001 (172.20.24.188): icmp_seq=1 ttl=64 time=0.039
>> ms', u'', u'--- vuhplabspawx001 ping statistics ---', u'1 packets
>> transmitted, 1 received, 0% packet loss, time 0ms', u'rtt min/avg/max/mdev
>> = 0.039/0.039/0.039/0.000 ms'],
>>
>> 172.20.24.188,vuhplabspawx001,x86_64,CentOS,7.2.1511
>> [root@vuhplabspawx001 tasks]#
>>
>>
>> How can i  sort this description to  only status and  result code  if
>> it  fails.
>>
>> Thanks in advance.:)
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CALJDb0mMwEGMXR3LP1vfOPjumBL9xkdYU9Hy-jRZNq_v%3DvhFMw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFbiokcDVo4uFVoq%3DLf%2B%3D8E1r7PhFxCtkSdVvtE8kjA04mTgyQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALJDb0%3DnsaG-6MjcrKCtZHD1k64PLeisXgHcB1uRo8uZz9qPpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ping module status in CSV

2019-04-18 Thread S C Rigler
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

On Thu, Apr 18, 2019 at 12:15 AM Vandana Thakur 
wrote:

> 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 :
>
>
> ---
>
> *  - ping:  register: result*
>
> *- debug: var=hostvars[inventory_hostname].result*
>
> - setup:
>   delegate_facts: True
>
> - lineinfile:
> create: yes
> dest: /{{csv_log}}/setup.csv
> line: *"Ping,*
> Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project"
> state: present
>   delegate_to: localhost
>   delegate_facts: True
>
> - lineinfile:
> create: yes
> regexp: "NONEXISTENTLINE"
> dest: /{{csv_log}}/setup.csv
> line: 
> *"{{ping_res.stdout_lines}},*{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}},{{
> inventory_hostname }},{{ ansible_architecture }},{{ ansible_distribution
> }},{{ ansible_distribution_version }}"
> state: present
>   delegate_to: localhost
>   delegate_facts: True
>
>
> BUT the issue is , it gives all the output like :
>
> [root@vuhplabspawx001 tasks]#   cat  /tmp/setup.csv
> Ping,Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project
>
> [u'PING vuhplabspawx001 (172.20.24.188) 56(84) bytes of data.', u'64 bytes
> from vuhplabspawx001 (172.20.24.188): icmp_seq=1 ttl=64 time=0.039 ms',
> u'', u'--- vuhplabspawx001 ping statistics ---', u'1 packets transmitted, 1
> received, 0% packet loss, time 0ms', u'rtt min/avg/max/mdev =
> 0.039/0.039/0.039/0.000 ms'],
>
> 172.20.24.188,vuhplabspawx001,x86_64,CentOS,7.2.1511
> [root@vuhplabspawx001 tasks]#
>
>
> How can i  sort this description to  only status and  result code  if  it
> fails.
>
> Thanks in advance.:)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CALJDb0mMwEGMXR3LP1vfOPjumBL9xkdYU9Hy-jRZNq_v%3DvhFMw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFbiokcDVo4uFVoq%3DLf%2B%3D8E1r7PhFxCtkSdVvtE8kjA04mTgyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ping module status in CSV

2019-04-17 Thread Vandana Thakur
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 :


---

*  - ping:  register: result*

*- debug: var=hostvars[inventory_hostname].result*

- setup:
  delegate_facts: True

- lineinfile:
create: yes
dest: /{{csv_log}}/setup.csv
line: *"Ping,*
Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project"
state: present
  delegate_to: localhost
  delegate_facts: True

- lineinfile:
create: yes
regexp: "NONEXISTENTLINE"
dest: /{{csv_log}}/setup.csv
line: 
*"{{ping_res.stdout_lines}},*{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}},{{
inventory_hostname }},{{ ansible_architecture }},{{ ansible_distribution
}},{{ ansible_distribution_version }}"
state: present
  delegate_to: localhost
  delegate_facts: True


BUT the issue is , it gives all the output like :

[root@vuhplabspawx001 tasks]#   cat  /tmp/setup.csv
Ping,Hostname,CPU_Architecture,OS,OS_VERSION,Customer_name,Location,Project

[u'PING vuhplabspawx001 (172.20.24.188) 56(84) bytes of data.', u'64 bytes
from vuhplabspawx001 (172.20.24.188): icmp_seq=1 ttl=64 time=0.039 ms',
u'', u'--- vuhplabspawx001 ping statistics ---', u'1 packets transmitted, 1
received, 0% packet loss, time 0ms', u'rtt min/avg/max/mdev =
0.039/0.039/0.039/0.000 ms'],

172.20.24.188,vuhplabspawx001,x86_64,CentOS,7.2.1511
[root@vuhplabspawx001 tasks]#


How can i  sort this description to  only status and  result code  if  it
fails.

Thanks in advance.:)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALJDb0mMwEGMXR3LP1vfOPjumBL9xkdYU9Hy-jRZNq_v%3DvhFMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.