From 1f21a30e7fd2e9ba832294fc4541eb88a9328458 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 18 May 2018 19:00:57 +0100 Subject: [PATCH] issue #251: ansible: watch for delegate_to during connection delegation. This needs more work -- pretty certain that python_path and suchlike are coming from the wrong place. Possibly we need another config_from_..() specialized for delegate_to. --- ansible_mitogen/connection.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index c0a17c17..12616dbf 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -524,13 +524,23 @@ class Connection(ansible.plugins.connection.ConnectionBase): broker=self.broker, ) - stack, _ = self._stack_from_config( - config_from_play_context( + if hasattr(self._play_context, 'delegate_to'): + target_config = config_from_hostvars( + transport=self._play_context.connection, + inventory_name=self._play_context.delegate_to, + connection=self, + hostvars=self.host_vars[self._play_context.delegate_to], + become_user=(self._play_context.become_user + if self._play_context.become + else None), + ) + else: + target_config = config_from_play_context( transport=self.transport, inventory_name=self.inventory_hostname, connection=self ) - ) + stack, _ = self._stack_from_config(target_config) dct = self.parent.call_service( service_name='ansible_mitogen.services.ContextService',