1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixed traceback when x_user implicitly sets the become method

Fixes #10430

Also removed redundant resolution of sudo/su for backwards compatibility which
confused the conflict detection code.
This commit is contained in:
Brian Coca 2015-03-11 12:18:53 -04:00
parent 1fd0a78b0e
commit de5eae2007
2 changed files with 18 additions and 26 deletions

View file

@ -583,29 +583,6 @@ class Play(object):
included_become_vars[k] = become_vars[k]
x[k] = become_vars[k]
## backwards compat with old sudo/su directives
if 'sudo' in x or 'sudo_user' in x:
included_become_vars['become'] = x['sudo']
x['become'] = x['sudo']
x['become_method'] = 'sudo'
del x['sudo']
if x.get('sudo_user', False):
included_become_vars['become_user'] = x['sudo_user']
x['become_user'] = x['sudo_user']
del x['sudo_user']
elif 'su' in x or 'su_user' in x:
included_become_vars['become'] = x['su']
x['become'] = x['su']
x['become_method'] = 'su'
del x['su']
if x.get('su_user', False):
included_become_vars['become_user'] = x['su_user']
x['become_user'] = x['su_user']
del x['su_user']
if 'meta' in x:
if x['meta'] == 'flush_handlers':
results.append(Task(self, x))

View file

@ -173,19 +173,34 @@ class Task(object):
# set only if passed in current task data
if 'sudo' in ds or 'sudo_user' in ds:
self.become=ds['sudo']
self.become_method='sudo'
if 'sudo' in ds:
self.become=ds['sudo']
del ds['sudo']
else:
self.become=True
if 'sudo_user' in ds:
self.become_user = ds['sudo_user']
del ds['sudo_user']
if 'sudo_pass' in ds:
self.become_pass = ds['sudo_pass']
if 'su' in ds or 'su_user' in ds:
self.become=ds['su']
del ds['sudo_pass']
elif 'su' in ds or 'su_user' in ds:
self.become_method='su'
if 'su' in ds:
self.become=ds['su']
else:
self.become=True
del ds['su']
if 'su_user' in ds:
self.become_user = ds['su_user']
del ds['su_user']
if 'su_pass' in ds:
self.become_pass = ds['su_pass']
del ds['su_pass']
# Both are defined
if ('action' in ds) and ('local_action' in ds):