Hello,
I am having a hard time in finding syntax needed for playbooks to loop over inventory with 30 routers (R1 to R30) where some values (IP addresses) are stored in an external .yml file.
Example of file storing IP addresses:
R:
R1:
index: 1
asn: 65101
ipv4: 172.20.0.1
ipv6: 2001:db8:d::1
R2:
index: 2
asn: 65102
ipv4: 172.20.0.2
ipv6: 2001:db8:d::2
R3:
index: 3
asn: 65103
ipv4: 172.20.0.3
ipv6: 2001:db8:d::3
What I want to achieve here is have a single task which loops inventory (R1…R30) and sets IP addresses. Due to some reason I cannot store these IPs, ASNs etc in inventory itself.
Pseudo code of what I want:
- name: Set IPv4 and IPv6 address on all 30 routers
some_module: - address R.{{ inventory_hostname )}.IPv4
- address R.{{ inventory_hostname )}.IPv6
Any advice on how to achieve this would be very helpful!
Thanks.