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

Clever-clever automated certificate download

Introduction # A client of mine needs some proper automation on his server. It’s a modest little container-based thing that runs a LAMP stack which powers a few tens of websites. I faced the prospect, for each website that was added to... Continue →