Commit 462cd4f7 by James Cammarata

Merge branch 'pulls/fix-hostvars-inconsistancy' of…

Merge branch 'pulls/fix-hostvars-inconsistancy' of https://github.com/ferringb/ansible into ferringb-pulls/fix-hostvars-inconsistancy
parents 7f37f8fd 31061213
...@@ -82,7 +82,7 @@ def _executor_hook(job_queue, result_queue, new_stdin): ...@@ -82,7 +82,7 @@ def _executor_hook(job_queue, result_queue, new_stdin):
except: except:
traceback.print_exc() traceback.print_exc()
class HostVars(dict): class HostVars(collections.Mapping):
''' A special view of setup_cache that adds values from the inventory when needed. ''' ''' A special view of setup_cache that adds values from the inventory when needed. '''
def __init__(self, setup_cache, inventory): def __init__(self, setup_cache, inventory):
...@@ -90,8 +90,6 @@ class HostVars(dict): ...@@ -90,8 +90,6 @@ class HostVars(dict):
self.inventory = inventory self.inventory = inventory
self.lookup = {} self.lookup = {}
self.update(setup_cache)
def __getitem__(self, host): def __getitem__(self, host):
if not host in self.lookup: if not host in self.lookup:
result = self.inventory.get_variables(host) result = self.inventory.get_variables(host)
...@@ -99,8 +97,12 @@ class HostVars(dict): ...@@ -99,8 +97,12 @@ class HostVars(dict):
self.lookup[host] = result self.lookup[host] = result
return self.lookup[host] return self.lookup[host]
def __contains__(self, host): def __iter__(self):
return host in self.lookup or host in self.setup_cache or self.inventory.get_host(host) return (host.name for host in self.inventory.get_group('all').hosts)
def __len__(self):
return len(self.inventory.get_group('all').hosts)
class Runner(object): class Runner(object):
''' core API interface to ansible ''' ''' core API interface to ansible '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment