From 220d224433415c02522a89ac4bf2389d2ec0c5f8 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Fri, 9 Nov 2018 15:22:23 -0500 Subject: [PATCH] add note regarding {host,group}_vars directory lookup semantics (#48066) * 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 * incorporates bcoca feedback --- docs/docsite/rst/user_guide/intro_inventory.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docsite/rst/user_guide/intro_inventory.rst b/docs/docsite/rst/user_guide/intro_inventory.rst index aa1c5f13240..b80fe1a1cbb 100644 --- a/docs/docsite/rst/user_guide/intro_inventory.rst +++ b/docs/docsite/rst/user_guide/intro_inventory.rst @@ -311,6 +311,10 @@ 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: 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. + 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.