mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
set correct become mehotds for plugin
fixed mixup with remote password vs become_password
This commit is contained in:
parent
ff443d4534
commit
bac35ae773
1 changed files with 6 additions and 6 deletions
|
@ -40,6 +40,8 @@ from ansible.plugins.connections import ConnectionBase
|
||||||
class Connection(ConnectionBase):
|
class Connection(ConnectionBase):
|
||||||
''' ssh based connections '''
|
''' ssh based connections '''
|
||||||
|
|
||||||
|
become_methods = frozenset(C.BECOME_METHODS).difference(['runas'])
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# SSH connection specific init stuff
|
# SSH connection specific init stuff
|
||||||
self._common_args = []
|
self._common_args = []
|
||||||
|
@ -261,7 +263,7 @@ class Connection(ConnectionBase):
|
||||||
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None, sudoable=True):
|
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None, sudoable=True):
|
||||||
''' run a command on the remote host '''
|
''' run a command on the remote host '''
|
||||||
|
|
||||||
super(Connection, self).exec_command(cmd, tmp_path, executable=executable, in_data=in_data, sudoable=False)
|
super(Connection, self).exec_command(cmd, tmp_path, executable=executable, in_data=in_data, sudoable=sudoable)
|
||||||
|
|
||||||
host = self._connection_info.remote_addr
|
host = self._connection_info.remote_addr
|
||||||
|
|
||||||
|
@ -303,13 +305,11 @@ class Connection(ConnectionBase):
|
||||||
# create process
|
# create process
|
||||||
(p, stdin) = self._run(ssh_cmd, in_data)
|
(p, stdin) = self._run(ssh_cmd, in_data)
|
||||||
|
|
||||||
if prompt:
|
self._send_password()
|
||||||
self._send_password()
|
|
||||||
|
|
||||||
no_prompt_out = ''
|
no_prompt_out = ''
|
||||||
no_prompt_err = ''
|
no_prompt_err = ''
|
||||||
q(self._connection_info.password)
|
if self._connection_info.become and sudoable and self._connection_info.become_pass:
|
||||||
if self._connection_info.become and sudoable and self._connection_info.password:
|
|
||||||
# several cases are handled for sudo privileges with password
|
# several cases are handled for sudo privileges with password
|
||||||
# * NOPASSWD (tty & no-tty): detect success_key on stdout
|
# * NOPASSWD (tty & no-tty): detect success_key on stdout
|
||||||
# * without NOPASSWD:
|
# * without NOPASSWD:
|
||||||
|
@ -349,7 +349,7 @@ class Connection(ConnectionBase):
|
||||||
|
|
||||||
if not self._connection_info.check_become_success(become_output, success_key):
|
if not self._connection_info.check_become_success(become_output, success_key):
|
||||||
if sudoable:
|
if sudoable:
|
||||||
stdin.write(self._connection_info.password + '\n')
|
stdin.write(self._connection_info.become_pass + '\n')
|
||||||
else:
|
else:
|
||||||
no_prompt_out += become_output
|
no_prompt_out += become_output
|
||||||
no_prompt_err += become_errput
|
no_prompt_err += become_errput
|
||||||
|
|
Loading…
Reference in a new issue