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
7a394dc7
Commit
7a394dc7
authored
Mar 17, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible: allow establishment of duplicate SSH connections
parent
86ede622
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
17 deletions
+38
-17
ansible_mitogen/connection.py
ansible_mitogen/connection.py
+8
-0
ansible_mitogen/services.py
ansible_mitogen/services.py
+9
-2
docs/ansible.rst
docs/ansible.rst
+21
-15
No files found.
ansible_mitogen/connection.py
View file @
7a394dc7
...
@@ -79,6 +79,9 @@ class Connection(ansible.plugins.connection.ConnectionBase):
...
@@ -79,6 +79,9 @@ class Connection(ansible.plugins.connection.ConnectionBase):
#: Set to 'ansible_ssh_timeout' by on_action_run().
#: Set to 'ansible_ssh_timeout' by on_action_run().
ansible_ssh_timeout
=
None
ansible_ssh_timeout
=
None
#: Set to 'mitogen_ssh_discriminator' by on_action_run()
mitogen_ssh_discriminator
=
None
def
__init__
(
self
,
play_context
,
new_stdin
,
original_transport
):
def
__init__
(
self
,
play_context
,
new_stdin
,
original_transport
):
assert
ansible_mitogen
.
process
.
MuxProcess
.
unix_listener_path
,
(
assert
ansible_mitogen
.
process
.
MuxProcess
.
unix_listener_path
,
(
'The "mitogen" connection plug-in may only be instantiated '
'The "mitogen" connection plug-in may only be instantiated '
...
@@ -104,6 +107,10 @@ class Connection(ansible.plugins.connection.ConnectionBase):
...
@@ -104,6 +107,10 @@ class Connection(ansible.plugins.connection.ConnectionBase):
executing. We use the opportunity to grab relevant bits from the
executing. We use the opportunity to grab relevant bits from the
task-specific data.
task-specific data.
"""
"""
self
.
mitogen_ssh_discriminator
=
task_vars
.
get
(
'mitogen_ssh_discriminator'
,
None
)
self
.
ansible_ssh_timeout
=
task_vars
.
get
(
self
.
ansible_ssh_timeout
=
task_vars
.
get
(
'ansible_ssh_timeout'
,
'ansible_ssh_timeout'
,
None
None
...
@@ -142,6 +149,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
...
@@ -142,6 +149,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
'method'
:
'ssh'
,
'method'
:
'ssh'
,
'check_host_keys'
:
False
,
# TODO
'check_host_keys'
:
False
,
# TODO
'hostname'
:
self
.
_play_context
.
remote_addr
,
'hostname'
:
self
.
_play_context
.
remote_addr
,
'discriminator'
:
self
.
mitogen_ssh_discriminator
,
'username'
:
self
.
_play_context
.
remote_user
,
'username'
:
self
.
_play_context
.
remote_user
,
'password'
:
self
.
_play_context
.
password
,
'password'
:
self
.
_play_context
.
password
,
'port'
:
self
.
_play_context
.
port
,
'port'
:
self
.
_play_context
.
port
,
...
...
ansible_mitogen/services.py
View file @
7a394dc7
...
@@ -47,8 +47,13 @@ class ContextService(mitogen.service.Service):
...
@@ -47,8 +47,13 @@ class ContextService(mitogen.service.Service):
having workers connect in directly.
having workers connect in directly.
:param dict dct:
:param dict dct:
Parameters passed to mitogen.master.Router.[method](). One key,
Parameters passed to `mitogen.master.Router.[method]()`.
"method", is popped from the dictionary and used to look up the method.
* The `method` key is popped from the dictionary and used to look up
the Mitogen connection method.
* The `discriminator` key is mixed into the key used to select an
existing connection, but popped from the list of arguments passed to
the connection method.
:returns mitogen.master.Context:
:returns mitogen.master.Context:
Corresponding Context instance.
Corresponding Context instance.
...
@@ -65,6 +70,8 @@ class ContextService(mitogen.service.Service):
...
@@ -65,6 +70,8 @@ class ContextService(mitogen.service.Service):
def
dispatch
(
self
,
dct
,
msg
):
def
dispatch
(
self
,
dct
,
msg
):
key
=
repr
(
sorted
(
dct
.
items
()))
key
=
repr
(
sorted
(
dct
.
items
()))
dct
.
pop
(
'discriminator'
,
None
)
if
key
not
in
self
.
_context_by_key
:
if
key
not
in
self
.
_context_by_key
:
method
=
getattr
(
self
.
router
,
dct
.
pop
(
'method'
))
method
=
getattr
(
self
.
router
,
dct
.
pop
(
'method'
))
self
.
_context_by_key
[
key
]
=
method
(
**
dct
)
self
.
_context_by_key
[
key
]
=
method
(
**
dct
)
...
...
docs/ansible.rst
View file @
7a394dc7
...
@@ -234,28 +234,34 @@ operation.
...
@@ -234,28 +234,34 @@ operation.
SSH Variables
SSH Variables
-------------
-------------
Matching Ansible's existing model, these variables are treated on a per-task
basis, causing establishment of additional reuseable interpreters as necessary
to match the configuration of each task.
This list will grow as more missing pieces are discovered.
This list will grow as more missing pieces are discovered.
* ansible_python_interpreter
* ``ansible_ssh_timeout``
* ansible_ssh_timeout
* ``ansible_host``, ``ansible_ssh_host``
* ansible_host, ansible_ssh_host
* ``ansible_user``, ``ansible_ssh_user``
* ansible_user, ansible_ssh_user
* ``ansible_port``, ``ssh_port``
* ansible_port, ssh_port
* ``ansible_ssh_executable``, ``ssh_executable``
* ansible_ssh_executable, ssh_executable
* ``ansible_ssh_private_key_file``
* ansible_ssh_private_key_file
* ``ansible_ssh_pass``, ``ansible_password`` (default: assume passwordless)
* ansible_ssh_pass, ansible_password (default: assume passwordless)
* ``ssh_args``, ``ssh_common_args``, ``ssh_extra_args``
* ssh_args, ssh_common_args, ssh_extra_args
* ``mitogen_ssh_discriminator``: if present, a string mixed into the key used
to deduplicate connections. This permits intentional duplicate Mitogen
connections to a single host, which is probably only useful for testing.
Sudo Variables
Sudo Variables
--------------
--------------
*
ansible_python_interpreter
*
``ansible_python_interpreter``
*
ansible_sudo_exe, ansible_become_exe
*
``ansible_sudo_exe``, ``ansible_become_exe``
*
ansible_sudo_user, ansible_become_user (default: root
)
*
``ansible_sudo_user``, ``ansible_become_user`` (default: ``root``
)
*
ansible_sudo_pass, ansible_become_pass
(default: assume passwordless)
*
``ansible_sudo_pass``, ``ansible_become_pass``
(default: assume passwordless)
*
sudo_flags, become_flags
*
``sudo_flags``, ``become_flags``
* ansible.cfg:
timeout
* ansible.cfg:
``timeout``
Docker Variables
Docker Variables
...
...
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