I am trying to see how I can setup an inventory file for an application that is all managed by uri calls.
I have multiple end points that will end up with some different vars by host. But I have the host as 127.0.0.1 since everything runs local I thought that would be the way to do it.
I am finding that since I have the same host in different groups it's taking the last car that gets set for all the groups, as designed from what I can see. Is the best option a different inventory file for each end point?
I recently ran into this same situation!
The best way I got around it is to set up a single inventory file and create an “all” group with the variable ansible_connection: “local”
This way, you can create whatever hosts you want and ansible won’t attempt to actually ssh to any of them, it will know to connect locally (unless you want to override ansible_connection on a host level).
Example:
all:
vars:
ansible_connection: “local”
children:
dbservers:
vars:
foo: “bar”
hosts:
dbserver1:
sys: “TEST”
Hope that helps!
It does thanks!! I had the same crazy idea this morning too. Using a dummy name did the trick.