From 292be2a982a6002138dd70fc346577f1f334a3d8 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 24 Feb 2016 13:08:59 -0500 Subject: [PATCH] Use abspath instead of realpath for group/host vars files The use of realpath means when following symlinks the actual path is used when loading these files in the VariableManager, which may not line up with the host or group name specified. Fixes #14545 --- lib/ansible/inventory/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 3d9ad3516d9..d10a731faaf 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -739,11 +739,11 @@ class Inventory(object): if group and host is None: # load vars in dir/group_vars/name_of_group - base_path = os.path.realpath(os.path.join(to_unicode(basedir, errors='strict'), "group_vars/%s" % group.name)) + base_path = os.path.abspath(os.path.join(to_unicode(basedir, errors='strict'), "group_vars/%s" % group.name)) results = combine_vars(results, self._variable_manager.add_group_vars_file(base_path, self._loader)) elif host and group is None: # same for hostvars in dir/host_vars/name_of_host - base_path = os.path.realpath(os.path.join(to_unicode(basedir, errors='strict'), "host_vars/%s" % host.name)) + base_path = os.path.abspath(os.path.join(to_unicode(basedir, errors='strict'), "host_vars/%s" % host.name)) results = combine_vars(results, self._variable_manager.add_host_vars_file(base_path, self._loader)) # all done, results is a dictionary of variables for this particular host.