So would it work if you just use stdout or is split required?

If split is required, pls show me the stdout output and what you need from
this value?

On Fri, May 28, 2021, 13:48 R.B. Kumar <seekuma...@gmail.com> wrote:

> Thank you.. Just by printing stdout, it shows all the data perfectly.  But
> when i try to grep it using split, it is showing "VARIABLE IS NOT FOUND"
>
> TASK [debug]
> ***************************************************************************************************************
> ok: [labrtr2.allmerica.com] => {
>     "var_ip_addr_0.stdout[0].split('\n')[1].split()[1]": "VARIABLE IS NOT
> DEFINED!"
> }
>
> if i remove stdout[0].split('\n')[1].split()[1]":  I am getting the output
> showing the IP address in the output
>
> On Friday, May 28, 2021 at 1:41:47 PM UTC+5:30 jatin....@gmail.com wrote:
>
>> Please try to print stdout value first and see what does it contain.
>> Stdout_lines may have your data.
>>
>> On Fri, May 28, 2021, 13:38 R.B. Kumar <seeku...@gmail.com> wrote:
>>
>>> Hello All - I am using Ansible version 2.7.18
>>>
>>> I am trying this code to get IP address of the Cisco Router interface.
>>> When i use {{ item }}, the IP address is not captured. Where as if i use a
>>> static value (eg: show ip interface brief gig 0/0/0), the IP address is
>>> captured and i can use it in the script.
>>>
>>> Can you help me what is the mistake here? Thanks
>>>
>>>   - name: get_ip
>>>       ios_command:
>>>         provider: "{{ cli }}"
>>>         commands: "show ip interface brief *{{ item }}"*
>>>       register: var_ip_addr_0
>>>
>>> *      with_items:*
>>> *        - gigabitEthernet0/0/0*
>>>
>>>     - debug: var="var_ip_addr_0.stdout[0].split('\n')[1].split()[1]"
>>>
>>> But, the output of the debug shows the value is not captured.
>>>
>>> TASK [debug]
>>> ***************************************************************************************************************
>>> ok: [labrtr2.allmerica.com] => {
>>>     "var_ip_addr_0.stdout[0].split('\n')[1].split()[1]":* "VARIABLE IS
>>> NOT DEFINED!"*
>>> }
>>>
>>> PLAY RECAP
>>> *****************************************************************************************************************
>>> labrtr2.allmerica.com      : ok=3    changed=0    unreachable=0
>>> failed=0
>>>
>>> --
>>> 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-proje...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/e11452df-60f8-4f11-afa8-fe1afb2749f1n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/e11452df-60f8-4f11-afa8-fe1afb2749f1n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cc364f87-41e7-437e-a267-83ded09405c1n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/cc364f87-41e7-437e-a267-83ded09405c1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEsEP16OZ1Sny44XsJH6FXZd0z-%2B0_9bMGwe-t_MBESnr%3DLHdA%40mail.gmail.com.

Reply via email to