Closed nqb closed 3 years ago
Thank you for your issue @nqb This is indeed the way we use Ansible, by creating each new server in host_vars (we copy the variables from Template_xx files into a new file per server), therefore it makes sense to store all host related variables in this file. I have added your suggestion for point 1 here : 2e8910490ee1f61350f75d25d3bb9818502b33f1
I understand that your solution would allow for people having inventory variables defined elsewhere, however this would split variables in 2 locations therefore I am not really in favor... What I did is that I added a create: yes argument so that if file does not exist it would create it (you would then have only these variables in this host_vars file instead of in a facts.d directory) here : bf764163c44776118d2590ae6df024d5dd4b9bc8
Let me know your thoughts ?
I have added your suggestion for point 1 here : 2e89104
Thanks!
Solution for 2. looks good to me.
I understand that your solution would allow for people having inventory variables defined elsewhere, however this would split variables in 2 locations therefore I am not really in favor...
In fact, it's possible to install a script in /etc/ansbile/facts.d
run by Ansible each time you gather facts. That way, you don't have to really store variables, Ansible will collect them.
IMHO, it's better to let Ansible detect host vars information directly on nodes in place of redefining a lot of informations inside inventory.
I guess both point of views are valid :) I have frequent issues with facts when using --start-at-task parameter since it would not collect facts in that case.
If you do not mind, I would keep my approach and close this issue. If you do mind, let me know.
Thanks for your feedback @remi-filament.
It's ok for me.
Hello,
When running
docker_server_step2
roles on a host, you should have:host_vars
directory created in directory where you runansible-playbook
commandhost_vars/name_of_your_host
createdOn my side, I used a directory
inventory
to storegroup_vars
andhost_vars
inside it with anansible.cfg
file.Regarding 1, I fixed it like this:
I'm thinking about 2. IMHO, it will be more simple to store such variables directly on host in
/etc/ansible/facts.d
as a local facts.