-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hostvars confusion #564
Comments
TLDR: Running your example on a single machine ( When you called the Ansible then got the variable information from The second play named To help you understand this, I would suggest having three systems setup: one as the systems (ex: lab1) you run Ansible from, and the other two (ex: lab2, lab3) as test end points to execute the playbooks against. These can be small VMs running in your lab and able to communicate with each other over SSH (i.e. add lab2 and lab3 into the the /etc/hosts file on lab1). Adjust your |
Ofc, my bad. I stopped thinking about the inventory as list of available hosts that would define the whole spectrum of available machines. The code was working as expected when I ran ansible-playbook -i localhost,testhost -l localhost -c local playbook.yml instead. No need to make testhost actually available at all. It would have been a bit concerning to me if Ansible would have loaded all files in all cases, no matter if required or referenced at all. Sorry for not re-building your lab-suggestion, but that solution was requiring simply less effort on my side. I'm sure it would have worked just as well. My only comment then would be that the quoted paragraph from the book does not give the context that a machine must be defined in the inventory, in order to resolve the host_vars files as well. Anyhow, I learned something new today that totally slipped my mind: host-variables of not-addressed hosts are available when included in an inventory. I think it's up to geerlingguy if he thinks that paragraph could benefit from rephrasing or not. thanks for the clarification. @dglinder |
Hi there,
I have trouble understanding a paragraph around page 98 regarding magic variables with host and group variables.
I was wondering how I missed that behavior and did a small test:
$ tree . ├── host_vars │ ├── localhost.yml │ └── testhost.yml └── playbook.yml
If I run this with the following
ansible-playbook
-command, the variable content fortesthost.yml
is not present.The text was updated successfully, but these errors were encountered: