diff --git a/v2/ansible/modules/core b/v2/ansible/modules/core index 256ce9dd4d..e355f7bf12 160000 --- a/v2/ansible/modules/core +++ b/v2/ansible/modules/core @@ -1 +1 @@ -Subproject commit 256ce9dd4dfbe2b0dc9eb5031812c8ab76418a22 +Subproject commit e355f7bf12465ed3f25a2147d6940179db2a26aa diff --git a/v2/ansible/playbook/conditional.py b/v2/ansible/playbook/conditional.py index 1e20f3ffc6..2d8db78bba 100644 --- a/v2/ansible/playbook/conditional.py +++ b/v2/ansible/playbook/conditional.py @@ -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) diff --git a/v2/ansible/playbook/role/__init__.py b/v2/ansible/playbook/role/__init__.py index ae083e5f92..0bdab79946 100644 --- a/v2/ansible/playbook/role/__init__.py +++ b/v2/ansible/playbook/role/__init__.py @@ -46,13 +46,21 @@ __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): - s = set() - for k,v in params.iteritems(): - if isinstance(v, dict): - s.update((k, hash_params(v))) - else: - s.update((k, v)) - return frozenset(s) + 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) # The role cache is used to prevent re-loading roles, which # may already exist. Keys into this cache are the SHA1 hash diff --git a/v2/ansible/plugins/connections/ssh.py b/v2/ansible/plugins/connections/ssh.py index ee7db0295b..b8bbc5c46f 100644 --- a/v2/ansible/plugins/connections/ssh.py +++ b/v2/ansible/plugins/connections/ssh.py @@ -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)) diff --git a/v2/ansible/vars/__init__.py b/v2/ansible/vars/__init__.py index e3cd64f541..f9e7cba9cd 100644 --- a/v2/ansible/vars/__init__.py +++ b/v2/ansible/vars/__init__.py @@ -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