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 <[email protected]> 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 [email protected]. > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEsEP16bdwnKHHCzWurcZAyKbe4zhaDP3Vnb0D20CzzvgyaHog%40mail.gmail.com.
