From cd455e8c586d38f9b4095fc339a2001157278431 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 16 Mar 2018 01:06:55 +0545 Subject: [PATCH] ansible: minor tidy up --- ansible_mitogen/connection.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index e7167d1c..cc184931 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -201,24 +201,23 @@ class Connection(ansible.plugins.connection.ConnectionBase): if self.connected: return - path = os.environ['MITOGEN_LISTENER_PATH'] self.broker = mitogen.master.Broker() self.router, self.parent = mitogen.unix.connect( - path=path, + path=os.environ['MITOGEN_LISTENER_PATH'], broker=self.broker, ) if self.original_transport == 'local': - if not self._play_context.become: - self.context = self._connect_local() - else: + if self._play_context.become: self.context = self._connect_sudo(python_path=sys.executable) + else: + self.context = self._connect_local() else: self.host = self._connect_ssh() - if not self._play_context.become: - self.context = self.host - else: + if self._play_context.become: self.context = self._connect_sudo(via=self.host) + else: + self.context = self.host def close(self): """