diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 74c6998b22..babc059e65 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -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)) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index a43c2ab89d..77cb97e5c0 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -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):