From d13ab9a02273426d481337af517420df4adb7249 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 15 Feb 2018 04:55:56 +0545 Subject: [PATCH] ansible: remove hard-wired UNIX socket path. --- ansible_mitogen/connection/mitogen.py | 5 ++++- ansible_mitogen/strategy/mitogen.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ansible_mitogen/connection/mitogen.py b/ansible_mitogen/connection/mitogen.py index 61f92d71..1be08d9e 100644 --- a/ansible_mitogen/connection/mitogen.py +++ b/ansible_mitogen/connection/mitogen.py @@ -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, diff --git a/ansible_mitogen/strategy/mitogen.py b/ansible_mitogen/strategy/mitogen.py index 8eab8408..b239e204 100644 --- a/ansible_mitogen/strategy/mitogen.py +++ b/ansible_mitogen/strategy/mitogen.py @@ -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)