Coverage for lib/ansible/vars/hostvars.py : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
'ansible_version', 'ansible_play_hosts', 'inventory_hostname', 'inventory_hostname_short', 'inventory_file', 'inventory_dir', 'groups', 'group_names', 'omit', 'playbook_dir', 'play_hosts', 'role_names', 'ungrouped', ]
except ImportError: from sha import sha as sha1
# Note -- this is a Mapping, not a MutableMapping ''' A special view of vars_cache that adds values from the inventory when needed. '''
self._variable_manager = variable_manager variable_manager._hostvars = self
self._inventory = inventory
# does not use inventory.hosts so it can create localhost on demand return self._inventory.get_host(host_name)
''' Similar to __getitem__, however the returned data is not run through the templating engine to expand variables in the hostvars. ''' host = self._find_host(host_name) if host is None: return Undefined(name="hostvars['%s']" % host_name)
return self._variable_manager.get_vars(host=host, include_hostvars=False)
data = self.raw_get(host_name) if isinstance(data, Undefined): return data return HostVarsVars(data, loader=self._loader)
self._variable_manager.set_host_variable(host, varname, value)
self._variable_manager.set_nonpersistent_facts(host, facts)
self._variable_manager.set_host_facts(host, facts)
# does not use inventory.hosts so it can create localhost on demand return self._find_host(host_name) is not None
for host in self._inventory.hosts: yield host
return len(self._inventory.hosts)
out = {} for host in self._inventory.hosts: out[host] = self.get(host) return repr(out)
self._vars = variables self._loader = loader
templar = Templar(variables=self._vars, loader=self._loader) foo = templar.template(self._vars[var], fail_on_undefined=False, static_vars=STATIC_VARS) return foo
return (var in self._vars)
for var in self._vars.keys(): yield var
return len(self._vars.keys())
return repr(self._vars) |