Grab a specific IP address from ansible facts

Use jinja2 filters to grab the 192.168.x.x address from a machine with multiple NICs:

{{ ansible_all_ipv4_addresses | ipaddr('192.168.0.0/16') | first }}

Of course, this assumes that you don’t have 2 NICs on the same subnet in the one system. If you want to deal with that, I’m sure there’s a way to do it, but unfortunately it’s not right here right now :)

 
1
Kudos
 
1
Kudos

Now read this

Run ad-hoc ansible commands against your vagrant box

OK, 4 years down the line, here’s my next pearl of wisdom. I’m not going to make statements about keeping this blog updated, because, as you can see, they generally fail :) I’m working with vagrant boxes running on a VMware vsphere... Continue →