|
|
@ -37,6 +37,7 @@ import sys
|
|
|
|
import termios
|
|
|
|
import termios
|
|
|
|
|
|
|
|
|
|
|
|
from ansible import constants as C
|
|
|
|
from ansible import constants as C
|
|
|
|
|
|
|
|
from ansible.plugins.loader import become_loader, cliconf_loader, connection_loader, httpapi_loader, netconf_loader, terminal_loader
|
|
|
|
from ansible.plugins.connection import ConnectionBase
|
|
|
|
from ansible.plugins.connection import ConnectionBase
|
|
|
|
from ansible.module_utils._text import to_text
|
|
|
|
from ansible.module_utils._text import to_text
|
|
|
|
from ansible.module_utils.connection import Connection as SocketConnection, write_to_file_descriptor
|
|
|
|
from ansible.module_utils.connection import Connection as SocketConnection, write_to_file_descriptor
|
|
|
@ -98,11 +99,20 @@ class Connection(ConnectionBase):
|
|
|
|
raise AnsibleError("Unable to find location of 'ansible-connection'. "
|
|
|
|
raise AnsibleError("Unable to find location of 'ansible-connection'. "
|
|
|
|
"Please set or check the value of ANSIBLE_CONNECTION_PATH")
|
|
|
|
"Please set or check the value of ANSIBLE_CONNECTION_PATH")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
|
|
|
env.update({
|
|
|
|
|
|
|
|
'ANSIBLE_BECOME_PLUGINS': become_loader.print_paths(),
|
|
|
|
|
|
|
|
'ANSIBLE_CLICONF_PLUGINS': cliconf_loader.print_paths(),
|
|
|
|
|
|
|
|
'ANSIBLE_CONNECTION_PLUGINS': connection_loader.print_paths(),
|
|
|
|
|
|
|
|
'ANSIBLE_HTTPAPI_PLUGINS': httpapi_loader.print_paths(),
|
|
|
|
|
|
|
|
'ANSIBLE_NETCONF_PLUGINS': netconf_loader.print_paths(),
|
|
|
|
|
|
|
|
'ANSIBLE_TERMINAL_PLUGINS': terminal_loader.print_paths(),
|
|
|
|
|
|
|
|
})
|
|
|
|
python = sys.executable
|
|
|
|
python = sys.executable
|
|
|
|
master, slave = pty.openpty()
|
|
|
|
master, slave = pty.openpty()
|
|
|
|
p = subprocess.Popen(
|
|
|
|
p = subprocess.Popen(
|
|
|
|
[python, ansible_connection, to_text(os.getppid())],
|
|
|
|
[python, ansible_connection, to_text(os.getppid())],
|
|
|
|
stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
|
|
stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env
|
|
|
|
)
|
|
|
|
)
|
|
|
|
os.close(slave)
|
|
|
|
os.close(slave)
|
|
|
|
|
|
|
|
|
|
|
|