|
|
@ -43,6 +43,7 @@ from ansible import constants as C
|
|
|
|
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
|
|
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
|
|
from ansible.plugins.connections import ConnectionBase
|
|
|
|
from ansible.plugins.connections import ConnectionBase
|
|
|
|
from ansible.utils.path import makedirs_safe
|
|
|
|
from ansible.utils.path import makedirs_safe
|
|
|
|
|
|
|
|
from ansible.utils.debug import debug
|
|
|
|
|
|
|
|
|
|
|
|
AUTHENTICITY_MSG="""
|
|
|
|
AUTHENTICITY_MSG="""
|
|
|
|
paramiko: The authenticity of host '%s' can't be established.
|
|
|
|
paramiko: The authenticity of host '%s' can't be established.
|
|
|
@ -216,17 +217,20 @@ class Connection(ConnectionBase):
|
|
|
|
|
|
|
|
|
|
|
|
self._display.vvv("EXEC %s" % cmd, host=self._connection_info.remote_addr)
|
|
|
|
self._display.vvv("EXEC %s" % cmd, host=self._connection_info.remote_addr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sudoable:
|
|
|
|
|
|
|
|
cmd, self.prompt, self.success_key = self._connection_info.make_become_cmd(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
no_prompt_out = ''
|
|
|
|
no_prompt_out = ''
|
|
|
|
no_prompt_err = ''
|
|
|
|
no_prompt_err = ''
|
|
|
|
become_output = ''
|
|
|
|
become_output = ''
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
chan.exec_command(cmd)
|
|
|
|
chan.exec_command(cmd)
|
|
|
|
if self._connection_info.become_pass:
|
|
|
|
if self.prompt:
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
if success_key in become_output or \
|
|
|
|
debug('Waiting for Privilege Escalation input')
|
|
|
|
(prompt and become_output.endswith(prompt)) or \
|
|
|
|
if self.check_become_success(become_output) or self.check_password_prompt(become_output):
|
|
|
|
utils.su_prompts.check_su_prompt(become_output):
|
|
|
|
|
|
|
|
break
|
|
|
|
break
|
|
|
|
chunk = chan.recv(bufsize)
|
|
|
|
chunk = chan.recv(bufsize)
|
|
|
|
if not chunk:
|
|
|
|
if not chunk:
|
|
|
@ -237,7 +241,7 @@ class Connection(ConnectionBase):
|
|
|
|
raise AnsibleError('ssh connection ' +
|
|
|
|
raise AnsibleError('ssh connection ' +
|
|
|
|
'closed waiting for password prompt')
|
|
|
|
'closed waiting for password prompt')
|
|
|
|
become_output += chunk
|
|
|
|
become_output += chunk
|
|
|
|
if success_key not in become_output:
|
|
|
|
if not self.check_become_success(become_output):
|
|
|
|
if self._connection_info.become:
|
|
|
|
if self._connection_info.become:
|
|
|
|
chan.sendall(self._connection_info.become_pass + '\n')
|
|
|
|
chan.sendall(self._connection_info.become_pass + '\n')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|