From 16efb45735899737aacc106f89014ee9551fd625 Mon Sep 17 00:00:00 2001 From: Jonas Eriksson Date: Wed, 24 Jul 2013 17:59:51 +0200 Subject: [PATCH] Fix playbook-local host_vars when running from . Since ansible 1.2, it became possible to place a host_vars directory in the same directory as a playbook, making it possible to keep host_vars local to that playbook there. However, due to python's os.path.dirname, a action such as: $ ansible-playbook pb.yml ..would not pick up the host_vars as os.path.dirname("pb.yml") returns "", unlike the unix command dirname that would return ".". Substituting "pb.yml" on the command line with "./pb.yml" would do the trick, but is not always intuitive. This patch solves the problem until python solves issue18547 [1]. [1] http://bugs.python.org/issue18547 --- lib/ansible/inventory/vars_plugins/group_vars.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/inventory/vars_plugins/group_vars.py b/lib/ansible/inventory/vars_plugins/group_vars.py index 405ee50f91d..521a30af2dc 100644 --- a/lib/ansible/inventory/vars_plugins/group_vars.py +++ b/lib/ansible/inventory/vars_plugins/group_vars.py @@ -40,7 +40,7 @@ class VarsModule(object): """ main body of the plugin, does actual loading """ inventory = self.inventory - self.pb_basedir = inventory.playbook_basedir() + self.pb_basedir = os.path.abspath(inventory.playbook_basedir()) # sort groups by depth so deepest groups can override the less deep ones groupz = sorted(inventory.groups_for_host(host.name), key=lambda g: g.depth)