mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Put back $PATH checking in ansible-connection call (#37933)
This commit is contained in:
parent
0df5cfd41f
commit
169209c32a
2 changed files with 30 additions and 6 deletions
|
@ -858,9 +858,21 @@ class TaskExecutor:
|
||||||
master, slave = pty.openpty()
|
master, slave = pty.openpty()
|
||||||
|
|
||||||
python = sys.executable
|
python = sys.executable
|
||||||
# Assume ansible-connection is in the same dir as sys.argv[0]
|
|
||||||
ansible_connection = os.path.join(os.path.dirname(sys.argv[0]), 'ansible-connection')
|
def find_file_in_path(filename):
|
||||||
p = subprocess.Popen([python, ansible_connection, to_text(os.getppid())], stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
# Check $PATH first, followed by same directory as sys.argv[0]
|
||||||
|
paths = os.environ['PATH'].split(os.pathsep) + [os.path.dirname(sys.argv[0])]
|
||||||
|
for dirname in paths:
|
||||||
|
fullpath = os.path.join(dirname, filename)
|
||||||
|
if os.path.isfile(fullpath):
|
||||||
|
return fullpath
|
||||||
|
|
||||||
|
raise AnsibleError("Unable to find location of '%s'" % filename)
|
||||||
|
|
||||||
|
p = subprocess.Popen(
|
||||||
|
[python, find_file_in_path('ansible-connection'), to_text(os.getppid())],
|
||||||
|
stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
|
)
|
||||||
stdin = os.fdopen(master, 'wb', 0)
|
stdin = os.fdopen(master, 'wb', 0)
|
||||||
os.close(slave)
|
os.close(slave)
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,21 @@ class Connection(ConnectionBase):
|
||||||
master, slave = pty.openpty()
|
master, slave = pty.openpty()
|
||||||
|
|
||||||
python = sys.executable
|
python = sys.executable
|
||||||
# Assume ansible-connection is in the same dir as sys.argv[0]
|
|
||||||
ansible_connection = os.path.join(os.path.dirname(sys.argv[0]), 'ansible-connection')
|
def find_file_in_path(filename):
|
||||||
p = subprocess.Popen([python, ansible_connection, to_text(os.getppid())], stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
# Check $PATH first, followed by same directory as sys.argv[0]
|
||||||
|
paths = os.environ['PATH'].split(os.pathsep) + [os.path.dirname(sys.argv[0])]
|
||||||
|
for dirname in paths:
|
||||||
|
fullpath = os.path.join(dirname, filename)
|
||||||
|
if os.path.isfile(fullpath):
|
||||||
|
return fullpath
|
||||||
|
|
||||||
|
raise AnsibleError("Unable to find location of '%s'" % filename)
|
||||||
|
|
||||||
|
p = subprocess.Popen(
|
||||||
|
[python, find_file_in_path('ansible-connection'), to_text(os.getppid())],
|
||||||
|
stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
|
)
|
||||||
stdin = os.fdopen(master, 'wb', 0)
|
stdin = os.fdopen(master, 'wb', 0)
|
||||||
os.close(slave)
|
os.close(slave)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue