Skip to content

Commit

Permalink
Merge branch 'bcoca-become_fixes' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Mar 11, 2015
2 parents ab45e5e + 747c7aa commit 5f0ed76
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bin/ansible-playbook
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def main(args):
options.ask_vault_pass = options.ask_vault_pass or C.DEFAULT_ASK_VAULT_PASS

if options.listhosts or options.syntax or options.listtasks or options.listtags:
(_, _, _, vault_pass) = utils.ask_passwords(ask_vault_pass=options.ask_vault_pass)
(_, _, vault_pass) = utils.ask_passwords(ask_vault_pass=options.ask_vault_pass)
else:
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
# Never ask for an SSH password when we run with local connection
Expand Down
2 changes: 1 addition & 1 deletion docsite/rst/intro_dynamic_inventory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For information about writing your own dynamic inventory source, see :doc:`devel
Example: The Cobbler External Inventory Script
``````````````````````````````````````````````

It is expected that many Ansible users with a reasonable amount of physical hardware may also be `Cobbler <http://cobbler.github.com>`_ users. (note: Cobbler was originally written by Michael DeHaan and is now lead by James Cammarata, who also works for Ansible, Inc).
It is expected that many Ansible users with a reasonable amount of physical hardware may also be `Cobbler <http://cobbler.github.com>`_ users. (note: Cobbler was originally written by Michael DeHaan and is now led by James Cammarata, who also works for Ansible, Inc).

While primarily used to kickoff OS installations and manage DHCP and DNS, Cobbler has a generic
layer that allows it to represent data for multiple configuration management systems (even at the same time), and has
Expand Down
23 changes: 0 additions & 23 deletions lib/ansible/playbook/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,29 +583,6 @@ def _load_tasks(self, tasks, vars=None, role_params=None, default_vars=None, bec
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))
Expand Down
21 changes: 18 additions & 3 deletions lib/ansible/playbook/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,34 @@ def __init__(self, play, ds, module_vars=None, play_vars=None, play_file_vars=No

# 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):
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/runner/action_plugins/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **
xfered = self.runner._transfer_str(conn, tmp, 'source', resultant)

# fix file permissions when the copy is done as a different user
if self.runner.become and self.runner.become_user != 'root' or self.runner.su and self.runner.su_user != 'root':
if self.runner.become and self.runner.become_user != 'root':
self.runner._remote_chmod(conn, 'a+r', xfered, tmp)

# run the copy module
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/runner/connection_plugins/paramiko_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def exec_command(self, cmd, tmp_path, become_user=None, sudoable=False, executab

if success_key in become_output or \
(prompt and become_output.endswith(prompt)) or \
utils.su_prompts.check_su_prompt(become_output)):
utils.su_prompts.check_su_prompt(become_output):
break
chunk = chan.recv(bufsize)

Expand Down

0 comments on commit 5f0ed76

Please sign in to comment.