diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index f085b0590e..9a2e39f139 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -68,8 +68,9 @@ class Task(object): self.name = ds.get('name', None) self.tags = [ 'all' ] self.register = ds.get('register', None) - self.sudo = ds.get('sudo', play.sudo) - if self.sudo is True: + self.sudo = utils.boolean(ds.get('sudo', play.sudo)) + + if self.sudo: self.sudo_user = ds.get('sudo_user', play.sudo_user) self.sudo_pass = ds.get('sudo_pass', play.playbook.sudo_pass) else: diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 92d1ef9c3d..30f995ee1c 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -499,3 +499,12 @@ def get_available_modules(dirname=None): modules_list.update(os.listdir(path)) modules_list = list(modules_list) return modules_list + +def boolean(value): + val = str(value) + if val.lower() in [ "true", "t", "y", "1", "yes" ]: + return True + else: + return False + +