Skip to content

Commit 8ebeaff

Browse files
committed
Disallow connection redirection of sub-connections if the top-level connection in the play is not a Mitogen connection.
1 parent d0afae7 commit 8ebeaff

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ansible_mitogen/strategy.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import ansible.executor.process.worker
4848
import ansible.template
4949
import ansible.utils.sentinel
50+
import ansible.playbook.play_context
5051
import ansible.plugins.loader
5152

5253

@@ -135,7 +136,17 @@ def wrap_connection_loader__get_with_context(name, *args, **kwargs):
135136
connection_loader.get_with_context() calls for some transports into
136137
requests for a compatible Mitogen transport.
137138
"""
138-
if name in REDIRECTED_CONNECTION_PLUGINS:
139+
is_play_using_mitogen_connection = None
140+
if len(args) > 0 and isinstance(args[0], ansible.playbook.play_context.PlayContext):
141+
play_context = args[0]
142+
is_play_using_mitogen_connection = play_context.connection in REDIRECTED_CONNECTION_PLUGINS
143+
144+
# assume true if we're not in a play context since we're using a Mitogen strategy
145+
if is_play_using_mitogen_connection is None:
146+
is_play_using_mitogen_connection = True
147+
148+
redirect_connection = name in REDIRECTED_CONNECTION_PLUGINS and is_play_using_mitogen_connection
149+
if redirect_connection:
139150
name = 'mitogen_' + name
140151

141152
return ansible_mitogen.loaders.connection_loader__get_with_context(name, *args, **kwargs)

0 commit comments

Comments
 (0)