From e2cc510e37ec61d0415145933acb070902aa84a1 Mon Sep 17 00:00:00 2001 From: Hagai Date: Thu, 22 May 2014 15:31:20 +0300 Subject: [PATCH 1/2] Update docs to include directories inside group_vars --- docsite/rst/intro_inventory.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docsite/rst/intro_inventory.rst b/docsite/rst/intro_inventory.rst index 789f4ac438a..24a8670cef2 100644 --- a/docsite/rst/intro_inventory.rst +++ b/docsite/rst/intro_inventory.rst @@ -171,6 +171,17 @@ the 'raleigh' group might look like:: It is ok if these files do not exist, as this is an optional feature. +As an advanced use-case, you can create *directories* named after your groups or hosts, and +Ansible will read all the files in these directories. An example with the 'raleigh' group:: + + /etc/ansible/group_vars/raleigh/db_settings + /etc/ansible/group_vars/raleigh/cluster_settings + +All hosts that are in the 'raleigh' group will have the variables defined in these files +available to them. This can be very useful to keep your variables organized when a single +file starts to be too big, or when you want to use :doc:`Ansible Vault` on a part of a group's +variables. + Tip: In Ansible 1.2 or later the group_vars/ and host_vars/ directories can exist in either the playbook directory OR the inventory directory. If both paths exist, variables in the playbook directory will be loaded second. From a552c072305b7d2c036f3015540ac1872111331e Mon Sep 17 00:00:00 2001 From: Hagai Date: Thu, 22 May 2014 17:54:21 +0300 Subject: [PATCH 2/2] Added note on which version did dirs in group_vars start working --- docsite/rst/intro_inventory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsite/rst/intro_inventory.rst b/docsite/rst/intro_inventory.rst index 24a8670cef2..a70f2b059ca 100644 --- a/docsite/rst/intro_inventory.rst +++ b/docsite/rst/intro_inventory.rst @@ -180,7 +180,7 @@ Ansible will read all the files in these directories. An example with the 'ralei All hosts that are in the 'raleigh' group will have the variables defined in these files available to them. This can be very useful to keep your variables organized when a single file starts to be too big, or when you want to use :doc:`Ansible Vault` on a part of a group's -variables. +variables. Note that this only works on Ansible 1.4 or later. Tip: In Ansible 1.2 or later the group_vars/ and host_vars/ directories can exist in either the playbook directory OR the inventory directory. If both paths exist, variables in the playbook