On Fri, 28 May 2021 08:21:43 -0700 (PDT)
"R.B. Kumar" <[email protected]> wrote:

> ... where the lines you shown here will fit in my script. My 
> script is below
> 
>     - name: get_ip
>       ios_command:
>         provider: "{{ cli }}"
>         commands: "show ip interface brief {{ item }}"
>       register: var_ip_addr

    - set_fact:
        interfaces: "{{ interfaces|default({})|
                        combine({_arr.0: _arr.1}) }}"
      loop: "{{ var_ip_addr.results|
                json_query('[].stdout_lines') }}"
      vars:
        _arr: "{{ item.0.1.split() }}"

    - debug:
        msg: "{{ interfaces[item] }}"
      loop:
        - GigabitEthernet0/0/0
        - Loopback0

gives

  msg: 42.151.182.42
  msg: 172.31.246.246

-- 
Vladimir Botka

-- 
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/20210528174418.3dc42473%40gmail.com.

Attachment: pgpsO43UngCXQ.pgp
Description: OpenPGP digital signature

Reply via email to