This is a pretty generic query that’s come up for me a lot over years. I’ve never really needed to resolve it but now I do.
I currently run an AWX installation that does basic management of various resources like patching etc. In some cases, I add hosts with names like server1.mydomain.com (where we have a DNS entry for the server), or more commonly something like 100.50.20.21 etc etc. This works well.
I would like to start managing some standard PCs that don’t have any such identifiers. Specifically, we have remote PCs that connect to our VPN (and AWX is peered to the VPN network) and when they do are assigned an address from 10.8.0.x.
I’m looking for a good way to do one of two (or ideally both) things.
- Find all the currently connected devices on that range and run some scripts on them
- Add hosts to my inventory where I don’t have a specific IP or FQDN for the device, i.e. some other identifier so that AWX knows where to go, then run some scripts on it.
For the second point, it could be that I ask everyone to be connected. Or ideally I could just run scripts on those that are connected at that time and report those that aren’t so that I could then run it later on specific hosts that were excluded the time before.
Bit complicated I know but my fundamental lack of knowledge of the inner workings of ansible is holding me back a bit here. It might be wishful thinking.