mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +00:00
Adapt to ansible python runtime
Unfortunately, python being python, ansible may elect to install under a different python runtime than confluent. In such a case, hope that the ansible python can work. Remove eventlet as a hard requirement, as that is unlikely to be in ansible python. This leaves msgpack, which is unavoidable, for now. But if it's in ansible python, it's fine.
This commit is contained in:
parent
795b4c513d
commit
013de4f881
@ -17,16 +17,17 @@
|
||||
|
||||
try:
|
||||
import confluent.sshutil as sshutil
|
||||
import eventlet
|
||||
import eventlet.green.subprocess as subprocess
|
||||
except ImportError:
|
||||
pass
|
||||
import eventlet
|
||||
import eventlet.green.subprocess as subprocess
|
||||
import json
|
||||
import msgpack
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
||||
anspypath = None
|
||||
running_status = {}
|
||||
class PlayRunner(object):
|
||||
def __init__(self, playfiles, nodes):
|
||||
@ -73,11 +74,22 @@ class PlayRunner(object):
|
||||
}
|
||||
|
||||
def _really_run_playbooks(self):
|
||||
global anspypath
|
||||
mypath = anspypath
|
||||
if not mypath:
|
||||
ansloc = shutil.which('ansible')
|
||||
if ansloc:
|
||||
with open(onsloc, 'r') as onsop:
|
||||
shebang = onsop.readline()
|
||||
anspypath = shebang.strip().replace('#!', '')
|
||||
mypath = anspypath
|
||||
if not mypath:
|
||||
mypath = sys.executable
|
||||
with open(os.devnull, 'w+') as devnull:
|
||||
targnodes = ','.join(self.nodes)
|
||||
for playfilename in self.playfiles:
|
||||
worker = subprocess.Popen(
|
||||
[sys.executable, __file__, targnodes, playfilename],
|
||||
[mypath, __file__, targnodes, playfilename],
|
||||
stdin=devnull, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, self.stderr = worker.communicate()
|
||||
|
Loading…
Reference in New Issue
Block a user