Hello Everyone again - Trying to get the IP address of the multiple Interfaces from a Cisco Router and register it. Using {{ item }} loop method to feed the Multiple Interfaces (eg: GigabitEthernet 0/0/0) in the command.
How to get the unique variables for each interface? I will pick those variables and going to use it in the same script.
For example i want to pint the IP address of GigabitEthernet 0/0/0, GigabitEthernet 0/0/1, GigabitEthernet 0/0/2,
All - I realised it is not possible or good idea to use {{ item }} in register. So i modified the code as below. So, now for all the three interface (GigabitEthernet 0/0/0,
Loopback 0) are captured in the same output and registered in var_ip_addr
The challenge now is, i have to grep IP address value from the output var_ip_addr. The IP address located under stdout. There are multiple stdout for each interface. How to grep the corresponding IP address from the output. debug: var=“var_ip_addr.results[0].stdout[0].split(‘\n’)[1].split()[1]” picks only the first interface. The control is not moving the subsequent Interfaces as the records are in the common hierarchy under result.
Thank you Vladimir - Much appreciated your response. Unfortunately, I am a ansible noob and trying to learn the things for a realtime network requirements
If you can help me where the lines you shown here will fit in my script. My script is below
Loopback 0
I have to use var_ip_addr in other places in the script such as configuring ACL.
For example I would look for GigabitEthernet 0/0/0 IP address from the var_ip_addr and use it in ACL. Again in the same script i will look for Loopback 0 in var_ip_addr and use it to configure router ID… Just for example.
Can you help me explaining how the instruction you provided will help here? Thanks