From d39ff55688f2cbc81f1a7076c21e7643d51d8ff0 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Mon, 14 Jul 2014 15:12:53 +0200 Subject: [PATCH 1/2] Fix logic bug when loading vars for a new playbook basedir. --- 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 da601ceb2c..90abb74fe2 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -585,11 +585,11 @@ class Inventory(object): def get_host_vars(self, host, new_pb_basedir=False): """ Read host_vars/ files """ - return self._get_hostgroup_vars(host=host, group=None, new_pb_basedir=False) + return self._get_hostgroup_vars(host=host, group=None, new_pb_basedir=new_pb_basedir) def get_group_vars(self, group, new_pb_basedir=False): """ Read group_vars/ files """ - return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=False) + return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir) def _get_hostgroup_vars(self, host=None, group=None, new_pb_basedir=False): """ From e8b45a9ef715d04713e49c5dc54d2a2ec87b3514 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Mon, 14 Jul 2014 15:21:33 +0200 Subject: [PATCH 2/2] Invalidate host/group variables cache when loading extra varsiables based on playbook basedir. --- lib/ansible/inventory/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 90abb74fe2..3999005c7a 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -582,6 +582,9 @@ class Inventory(object): # get host vars from host_vars/ files for host in self.get_hosts(): host.vars = utils.combine_vars(host.vars, self.get_host_vars(host, new_pb_basedir=True)) + # invalidate cache + self._vars_per_host = {} + self._vars_per_group = {} def get_host_vars(self, host, new_pb_basedir=False): """ Read host_vars/ files """