Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
e0382ab2
Commit
e0382ab2
authored
Mar 01, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible: teach ActionModule to disappear for non-Mitogen Connections
Closes #103.
parent
bde6f888
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
ansible_mitogen/mixins.py
ansible_mitogen/mixins.py
+17
-0
No files found.
ansible_mitogen/mixins.py
View file @
e0382ab2
...
...
@@ -47,6 +47,7 @@ import mitogen.core
import
mitogen.master
from
mitogen.utils
import
cast
import
ansible_mitogen.connection
import
ansible_mitogen.helpers
from
ansible.module_utils._text
import
to_text
...
...
@@ -95,6 +96,22 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
that crop up due to this. Mitogen always runs a task completely within
the target user account, so it's not a problem for us.
"""
def
__init__
(
self
,
task
,
connection
,
*
args
,
**
kwargs
):
"""
Verify the received connection is really a Mitogen connection. If not,
transmute this instance back into the original unadorned base class.
This allows running the Mitogen strategy in mixed-target playbooks,
where some targets use SSH while others use WinRM or some fancier UNIX
connection plug-in. That's because when the Mitogen strategy is active,
ActionModuleMixin is unconditionally mixed into any action module that
is instantiated, and there is no direct way for the monkey-patch to
know what kind of connection will be used upfront.
"""
super
(
ActionModuleMixin
,
self
).
__init__
(
task
,
connection
,
*
args
,
**
kwargs
)
if
not
isinstance
(
connection
,
ansible_mitogen
.
connection
.
Connection
):
_
,
self
.
__class__
=
type
(
self
).
__bases__
def
run
(
self
,
tmp
=
None
,
task_vars
=
None
):
"""
Override run() to notify Connection of task-specific data, so it has a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment