will only use “host1 var1=d var2=e var3=f”.
Is there a way to stop this and not have to split out the “duplicates” into multiple inventory files.
thx
lost_in_ansible
it is not ignoring the line, it is just merging them since you define host1 twice and inventory_hostname is a unique identifier, so any conflicting variables will be updated to the value last defined. Try adding var4 only to the first line and var5 only to the 2nd, you’ll see that they both exist and have the expected value.
Also splitting into multiple files will do nothing as the inventory is merged from all sources before execution starts.
thank you for this, makes sense, but did not work, it took the last values again. this reply does explain how its working tho…
I guess i’ll have to “awk” it out to unique files
thanks again for your help and patience
lia
this is a secure system , i can’t show more than what I have disclosed, but when I execute the above statement , yes I get similar output.
what i can tell you is that the those “two” lines ( I actually have upto 12 changes going to 30 different servers ) make database call to change two different parameters (positional parameters) and only the last is being performed.
anything else, you want me to try, please advise.
thanks
LIA
You do not need to show your confidential data, but you should show a full reproducer of the issue, as of now I cannot grasp what the real issue is as my example proves it works as I said, but you give me no example of the contrary.
Ok, so my final solution for this was to write a shell script that sorts the inventory file, break is into unique [groups], then create a template yml file to be "SED"ed by the number of groups and create a new yml file that is repeated n times (groups) so:
inventory file:
[group1]
x
x
[group2]
x
x
[groupn]
x
and the yml file:
— (three dashes)
hosts group1( dash )
code a
hosts group2 ( dash )
code a
hosts groupn ( dash )
code a
yes, its very kludggy, but it works as needed
thanks again Brian for the explanation, on what was happening,
I realize that this probably not how its suppose to work/be used…
LIA