From a768e9a9ffeb93894acb4a83343981535473f861 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 27 Oct 2012 16:46:33 -0400 Subject: [PATCH] Fix for sudo defaults if sudo is passed in via --extra-vars --- lib/ansible/playbook/task.py | 5 +++-- lib/ansible/utils.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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 + +