From 31909903646eed42cb25d71a65e8a81e6da1fe10 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Sun, 4 Nov 2018 15:26:31 -0500 Subject: [PATCH 1/2] add note regarding {host,group}_vars directory lookup semantics While the 'ansible-playbook' command will look for {host,group}_vars in both the playbook and inventory directories, the 'ansible' command will only look in the inventory directory. This follows from a close reading of the documentation but isn't explicit and leads to the perhaps unexpected result that you can run both commands with the same configuration in the same directory and get different results. This commit adds a note to the documentation making the difference in behavior explicit. Closes #48065 --- docs/docsite/rst/user_guide/intro_inventory.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docsite/rst/user_guide/intro_inventory.rst b/docs/docsite/rst/user_guide/intro_inventory.rst index e2c62fc239b688..b3d6a6eb0f33ee 100644 --- a/docs/docsite/rst/user_guide/intro_inventory.rst +++ b/docs/docsite/rst/user_guide/intro_inventory.rst @@ -308,6 +308,12 @@ Tip: The ``group_vars/`` and ``host_vars/`` directories can exist in the playbook directory OR the inventory directory. If both paths exist, variables in the playbook directory will override variables set in the inventory directory. +Tip: When running the ``ansible`` command (rather than +``ansible-playbook``) there is by default no "playbook directory". The +command will only look for ``group_vars/`` and ``host_vars/`` in the +inventory directory unless you provide the ``--playbook-dir`` option +on the command line. + Tip: Keeping your inventory file and variables in a git repo (or other version control) is an excellent way to track changes to your inventory and host variables. From 317591558653795e32f20009f233d9c82f0eb3c0 Mon Sep 17 00:00:00 2001 From: Alicia Cozine Date: Fri, 9 Nov 2018 13:37:25 -0600 Subject: [PATCH 2/2] incorporates bcoca feedback --- docs/docsite/rst/user_guide/intro_inventory.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/docsite/rst/user_guide/intro_inventory.rst b/docs/docsite/rst/user_guide/intro_inventory.rst index b3d6a6eb0f33ee..9522331d1c76bf 100644 --- a/docs/docsite/rst/user_guide/intro_inventory.rst +++ b/docs/docsite/rst/user_guide/intro_inventory.rst @@ -140,7 +140,7 @@ As described above, it is easy to assign variables to hosts that will be used la The YAML version: .. code-block:: yaml - + atlanta: host1: http_port: 80 @@ -308,9 +308,7 @@ Tip: The ``group_vars/`` and ``host_vars/`` directories can exist in the playbook directory OR the inventory directory. If both paths exist, variables in the playbook directory will override variables set in the inventory directory. -Tip: When running the ``ansible`` command (rather than -``ansible-playbook``) there is by default no "playbook directory". The -command will only look for ``group_vars/`` and ``host_vars/`` in the +Tip: The ``ansible-playbook`` command looks for playbooks in the current working directory by default. Other Ansible commands (for example, ``ansible``, ``ansible-console``, etc.) will only look for ``group_vars/`` and ``host_vars/`` in the inventory directory unless you provide the ``--playbook-dir`` option on the command line. @@ -508,4 +506,3 @@ Here is an example of how to instantly deploy to created containers:: Questions? Help? Ideas? Stop by the list on Google Groups `irc.freenode.net `_ #ansible IRC chat channel -