Fixing more v2 bugs

pull/10133/head
James Cammarata 10 years ago
parent d57f7b4b9e
commit c978c77796

@ -1 +1 @@
Subproject commit 256ce9dd4dfbe2b0dc9eb5031812c8ab76418a22
Subproject commit e355f7bf12465ed3f25a2147d6940179db2a26aa

@ -53,7 +53,7 @@ class Conditional:
False if any of them evaluate as such.
'''
templar = Templar(loader=self._loader, variables=all_vars)
templar = Templar(loader=self._loader, variables=all_vars, fail_on_undefined=False)
for conditional in self.when:
if not self._check_conditional(conditional, templar, all_vars):
return False
@ -69,20 +69,15 @@ class Conditional:
if conditional is None or conditional == '':
return True
# FIXME: is this required? there is no indication what it does
#conditional = conditional.replace("jinja2_compare ","")
# FIXME: this should be removable now, leaving it here just in case
# allow variable names
#if conditional in all_vars and '-' not in str(all_vars[conditional]):
# conditional = all_vars[conditional]
conditional = templar.template(conditional, convert_bare=True)
if not isinstance(conditional, basestring):
if not isinstance(conditional, basestring) or conditional == "":
return conditional
# FIXME: same as above
#original = str(conditional).replace("jinja2_compare ","")
# a Jinja2 evaluation that results in something Python can eval!
presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional
conditional = templar.template(presented)

@ -46,10 +46,18 @@ __all__ = ['Role', 'ROLE_CACHE', 'hash_params']
# in a static method. This is also used in the base class for
# strategies (ansible/plugins/strategies/__init__.py)
def hash_params(params):
if not isinstance(params, dict):
return params
else:
s = set()
for k,v in params.iteritems():
if isinstance(v, dict):
s.update((k, hash_params(v)))
elif isinstance(v, list):
things = []
for item in v:
things.append(hash_params(item))
s.update((k, tuple(things)))
else:
s.update((k, v))
return frozenset(s)

@ -279,7 +279,7 @@ class Connection(ConnectionBase):
# ssh_cmd += ['-6']
ssh_cmd += [self._host.ipv4_address]
if not (self._connection_info.sudo or self._connection_info.su) or not sudoable:
if not (self._connection_info.sudo or self._connection_info.su):
prompt = None
if executable:
ssh_cmd.append(executable + ' -c ' + pipes.quote(cmd))

@ -210,6 +210,9 @@ class VariableManager:
hostvars = HostVars(vars_manager=self, inventory=self._inventory, loader=loader)
all_vars['hostvars'] = hostvars
if self._inventory is not None:
all_vars['inventory_dir'] = self._inventory.basedir()
# the 'omit' value alows params to be left out if the variable they are based on is undefined
all_vars['omit'] = self._omit_token

Loading…
Cancel
Save