Skip to content

Commit

Permalink
Fix for sudo defaults if sudo is passed in via --extra-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdehaan committed Oct 27, 2012
1 parent 7d7ff9d commit a768e9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ansible/playbook/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def __init__(self, play, ds, module_vars=None):
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:
Expand Down
9 changes: 9 additions & 0 deletions lib/ansible/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit a768e9a

Please sign in to comment.