ansible: remove hard-wired UNIX socket path.

wip-fakessh-exit-status
David Wilson 7 years ago
parent 20afa5b90c
commit d13ab9a022

@ -43,6 +43,7 @@ Enable it by:
"""
from __future__ import absolute_import
import os
import ansible.errors
import ansible.plugins.connection
@ -65,7 +66,9 @@ class Connection(ansible.plugins.connection.ConnectionBase):
if self.connected:
return
self.router, self.parent = mitogen.unix.connect('/tmp/mitosock')
path = os.environ['LISTENER_SOCKET_PATH']
self.router, self.parent = mitogen.unix.connect(path)
host = mitogen.service.call(self.parent, 500, {
'method': 'ssh',
'hostname': self._play_context.remote_addr,

@ -74,7 +74,9 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule):
def run(self, iterator, play_context, result=0):
self.router = mitogen.master.Router()
self.listener = mitogen.unix.Listener(self.router, path='/tmp/mitosock')
self.listener = mitogen.unix.Listener(self.router)
os.environ['LISTENER_SOCKET_PATH'] = self.listener.path
self.service = ContextProxyService(self.router)
mitogen.utils.log_to_file()
@ -97,3 +99,4 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule):
return super(StrategyModule, self).run(iterator, play_context)
finally:
self.router.broker.shutdown()
os.unlink(self.listener.path)

Loading…
Cancel
Save