2019-02-13 16:16:49 +00:00
|
|
|
# Copyright 2019, David Wilson
|
2019-01-22 01:25:46 +00:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions and the following disclaimer in the documentation
|
|
|
|
# and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
|
|
# may be used to endorse or promote products derived from this software without
|
|
|
|
# specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import unicode_literals
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
"""
|
2019-01-22 01:25:46 +00:00
|
|
|
Mitogen extends Ansible's target configuration mechanism in several ways that
|
|
|
|
require some care:
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
* Per-task configurables in Ansible like ansible_python_interpreter are
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
connection-layer configurables in Mitogen. They must be extracted during each
|
|
|
|
task execution to form the complete connection-layer configuration.
|
|
|
|
|
|
|
|
* Mitogen has extra configurables not supported by Ansible at all, such as
|
|
|
|
mitogen_ssh_debug_level. These are extracted the same way as
|
|
|
|
ansible_python_interpreter.
|
|
|
|
|
|
|
|
* Mitogen allows connections to be delegated to other machines. Ansible has no
|
|
|
|
internal framework for this, and so Mitogen must figure out a delegated
|
2019-01-22 01:25:46 +00:00
|
|
|
connection configuration all on its own. It cannot reuse much of the Ansible
|
|
|
|
machinery for building a connection configuration, as that machinery is
|
|
|
|
deeply spread out and hard-wired to expect Ansible's usual mode of operation.
|
|
|
|
|
|
|
|
For normal and delegate_to connections, Ansible's PlayContext is reused where
|
|
|
|
possible to maximize compatibility, but for proxy hops, configurations are
|
|
|
|
built up using the HostVars magic class to call VariableManager.get_vars()
|
|
|
|
behind the scenes on our behalf. Where Ansible has multiple sources of a
|
|
|
|
configuration item, for example, ansible_ssh_extra_args, Mitogen must (ideally
|
|
|
|
perfectly) reproduce how Ansible arrives at its value, without using mechanisms
|
|
|
|
that are hard-wired or change across Ansible versions.
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
That is what this file is for. It exports two spec classes, one that takes all
|
|
|
|
information from PlayContext, and another that takes (almost) all information
|
|
|
|
from HostVars.
|
|
|
|
"""
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
import abc
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
import os
|
|
|
|
import ansible.utils.shlex
|
|
|
|
import ansible.constants as C
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
from ansible.module_utils.six import with_metaclass
|
|
|
|
|
2020-02-05 23:34:47 +00:00
|
|
|
# this was added in Ansible >= 2.8.0; fallback to the default interpreter if necessary
|
|
|
|
try:
|
|
|
|
from ansible.executor.interpreter_discovery import discover_interpreter
|
2020-02-05 23:40:25 +00:00
|
|
|
except ImportError:
|
2020-02-19 01:29:26 +00:00
|
|
|
discover_interpreter = lambda action,interpreter_name,discovery_mode,task_vars: '/usr/bin/python'
|
2020-02-05 23:34:47 +00:00
|
|
|
|
2020-02-12 02:46:14 +00:00
|
|
|
try:
|
|
|
|
from ansible.utils.unsafe_proxy import AnsibleUnsafeText
|
|
|
|
except ImportError:
|
|
|
|
from ansible.vars.unsafe_proxy import AnsibleUnsafeText
|
2019-01-22 01:25:46 +00:00
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
import mitogen.core
|
|
|
|
|
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_python):
|
2020-01-30 23:44:20 +00:00
|
|
|
"""
|
|
|
|
Triggers ansible python interpreter discovery if requested.
|
|
|
|
Caches this value the same way Ansible does it.
|
2020-03-03 22:50:50 +00:00
|
|
|
For connections like `docker`, we want to rediscover the python interpreter because
|
|
|
|
it could be different than what's ran on the host
|
2020-01-30 23:44:20 +00:00
|
|
|
"""
|
2020-03-04 06:03:49 +00:00
|
|
|
# keep trying different interpreters until we don't error
|
|
|
|
if action._finding_python_interpreter:
|
|
|
|
return action._possible_python_interpreter
|
|
|
|
|
2020-01-30 23:44:20 +00:00
|
|
|
if s in ['auto', 'auto_legacy', 'auto_silent', 'auto_legacy_silent']:
|
2020-03-03 22:50:50 +00:00
|
|
|
# python is the only supported interpreter_name as of Ansible 2.8.8
|
2020-01-30 23:44:20 +00:00
|
|
|
interpreter_name = 'python'
|
|
|
|
discovered_interpreter_config = u'discovered_interpreter_%s' % interpreter_name
|
2020-02-01 01:08:43 +00:00
|
|
|
|
|
|
|
if task_vars.get('ansible_facts') is None:
|
|
|
|
task_vars['ansible_facts'] = {}
|
2020-01-30 23:44:20 +00:00
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
if rediscover_python and task_vars.get('ansible_facts', {}).get(discovered_interpreter_config):
|
2020-03-04 06:03:49 +00:00
|
|
|
# if we're rediscovering python then chances are we're running something like a docker connection
|
|
|
|
# this will handle scenarios like running a playbook that does stuff + then dynamically creates a docker container,
|
|
|
|
# then runs the rest of the playbook inside that container, and then rerunning the playbook again
|
|
|
|
action._rediscovered_python = True
|
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
# blow away the discovered_interpreter_config cache and rediscover
|
|
|
|
del task_vars['ansible_facts'][discovered_interpreter_config]
|
|
|
|
|
2020-02-01 01:08:43 +00:00
|
|
|
if discovered_interpreter_config not in task_vars['ansible_facts']:
|
|
|
|
action._finding_python_interpreter = True
|
2020-02-01 01:22:49 +00:00
|
|
|
# fake pipelining so discover_interpreter can be happy
|
|
|
|
action._connection.has_pipelining = True
|
2020-01-30 23:44:20 +00:00
|
|
|
s = AnsibleUnsafeText(discover_interpreter(
|
|
|
|
action=action,
|
|
|
|
interpreter_name=interpreter_name,
|
|
|
|
discovery_mode=s,
|
|
|
|
task_vars=task_vars))
|
2020-03-04 06:03:49 +00:00
|
|
|
|
2020-01-30 23:44:20 +00:00
|
|
|
# cache discovered interpreter
|
2020-02-01 01:08:43 +00:00
|
|
|
task_vars['ansible_facts'][discovered_interpreter_config] = s
|
2020-02-01 01:22:49 +00:00
|
|
|
action._connection.has_pipelining = False
|
2020-01-30 23:44:20 +00:00
|
|
|
else:
|
2020-02-01 01:08:43 +00:00
|
|
|
s = task_vars['ansible_facts'][discovered_interpreter_config]
|
|
|
|
|
2020-02-03 22:51:50 +00:00
|
|
|
# propagate discovered interpreter as fact
|
|
|
|
action._discovered_interpreter_key = discovered_interpreter_config
|
|
|
|
action._discovered_interpreter = s
|
|
|
|
|
2020-02-01 01:08:43 +00:00
|
|
|
action._finding_python_interpreter = False
|
2020-01-30 23:44:20 +00:00
|
|
|
return s
|
2020-02-01 01:08:43 +00:00
|
|
|
|
2020-01-30 23:44:20 +00:00
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
def parse_python_path(s, task_vars, action, rediscover_python):
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
"""
|
|
|
|
Given the string set for ansible_python_interpeter, parse it using shell
|
2020-01-30 23:44:20 +00:00
|
|
|
syntax and return an appropriate argument vector. If the value detected is
|
|
|
|
one of interpreter discovery then run that first. Caches python interpreter
|
|
|
|
discovery value in `facts_from_task_vars` like how Ansible handles this.
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
"""
|
2020-03-03 22:50:50 +00:00
|
|
|
if not s:
|
|
|
|
# if python_path doesn't exist, default to `auto` and attempt to discover it
|
|
|
|
s = 'auto'
|
|
|
|
|
|
|
|
s = run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_python)
|
|
|
|
# if unable to determine python_path, fallback to '/usr/bin/python'
|
|
|
|
if not s:
|
|
|
|
s = '/usr/bin/python'
|
|
|
|
|
|
|
|
return ansible.utils.shlex.shlex_split(s)
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
def optional_secret(value):
|
|
|
|
"""
|
|
|
|
Wrap `value` in :class:`mitogen.core.Secret` if it is not :data:`None`,
|
|
|
|
otherwise return :data:`None`.
|
|
|
|
"""
|
|
|
|
if value is not None:
|
|
|
|
return mitogen.core.Secret(value)
|
|
|
|
|
|
|
|
|
2019-01-27 04:44:24 +00:00
|
|
|
def first_true(it, default=None):
|
|
|
|
"""
|
|
|
|
Return the first truthy element from `it`.
|
|
|
|
"""
|
|
|
|
for elem in it:
|
|
|
|
if elem:
|
|
|
|
return elem
|
|
|
|
return default
|
|
|
|
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
class Spec(with_metaclass(abc.ABCMeta, object)):
|
|
|
|
"""
|
|
|
|
A source for variables that comprise a connection configuration.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def transport(self):
|
|
|
|
"""
|
|
|
|
The name of the Ansible plug-in implementing the connection.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def inventory_name(self):
|
|
|
|
"""
|
|
|
|
The name of the target being connected to as it appears in Ansible's
|
|
|
|
inventory.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def remote_addr(self):
|
|
|
|
"""
|
|
|
|
The network address of the target, or for container and other special
|
|
|
|
targets, some other unique identifier.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def remote_user(self):
|
|
|
|
"""
|
|
|
|
The username of the login account on the target.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def password(self):
|
|
|
|
"""
|
|
|
|
The password of the login account on the target.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def become(self):
|
|
|
|
"""
|
|
|
|
:data:`True` if privilege escalation should be active.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def become_method(self):
|
|
|
|
"""
|
|
|
|
The name of the Ansible become method to use.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def become_user(self):
|
|
|
|
"""
|
|
|
|
The username of the target account for become.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def become_pass(self):
|
|
|
|
"""
|
|
|
|
The password of the target account for become.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def port(self):
|
|
|
|
"""
|
|
|
|
The port of the login service on the target machine.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def python_path(self):
|
|
|
|
"""
|
|
|
|
Path to the Python interpreter on the target machine.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def private_key_file(self):
|
|
|
|
"""
|
|
|
|
Path to the SSH private key file to use to login.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def ssh_executable(self):
|
|
|
|
"""
|
|
|
|
Path to the SSH executable.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def timeout(self):
|
|
|
|
"""
|
|
|
|
The generic timeout for all connections.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def ansible_ssh_timeout(self):
|
|
|
|
"""
|
|
|
|
The SSH-specific timeout for a connection.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def ssh_args(self):
|
|
|
|
"""
|
|
|
|
The list of additional arguments that should be included in an SSH
|
|
|
|
invocation.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def become_exe(self):
|
|
|
|
"""
|
|
|
|
The path to the executable implementing the become method on the remote
|
|
|
|
machine.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def sudo_args(self):
|
|
|
|
"""
|
|
|
|
The list of additional arguments that should be included in a become
|
|
|
|
invocation.
|
|
|
|
"""
|
|
|
|
# TODO: split out into sudo_args/become_args.
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_via(self):
|
|
|
|
"""
|
|
|
|
The value of the mitogen_via= variable for this connection. Indicates
|
|
|
|
the connection should be established via an intermediary.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_kind(self):
|
|
|
|
"""
|
|
|
|
The type of container to use with the "setns" transport.
|
|
|
|
"""
|
|
|
|
|
2019-04-16 20:15:31 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_mask_remote_name(self):
|
|
|
|
"""
|
|
|
|
Specifies whether to set a fixed "remote_name" field. The remote_name
|
|
|
|
is the suffix of `argv[0]` for remote interpreters. By default it
|
|
|
|
includes identifying information from the local process, which may be
|
|
|
|
undesirable in some circumstances.
|
|
|
|
"""
|
|
|
|
|
2019-06-08 23:06:30 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_buildah_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "buildah" program for the 'buildah' transport.
|
|
|
|
"""
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_docker_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "docker" program for the 'docker' transport.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_kubectl_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "kubectl" program for the 'docker' transport.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_lxc_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "lxc" program for the 'lxd' transport.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_lxc_attach_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "lxc-attach" program for the 'lxc' transport.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_lxc_info_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "lxc-info" program for the 'lxc' transport.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_machinectl_path(self):
|
|
|
|
"""
|
|
|
|
The path to the "machinectl" program for the 'setns' transport.
|
|
|
|
"""
|
|
|
|
|
2019-06-03 16:40:58 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_ssh_keepalive_interval(self):
|
|
|
|
"""
|
|
|
|
The SSH ServerAliveInterval.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_ssh_keepalive_count(self):
|
|
|
|
"""
|
|
|
|
The SSH ServerAliveCount.
|
|
|
|
"""
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_ssh_debug_level(self):
|
|
|
|
"""
|
|
|
|
The SSH debug level.
|
|
|
|
"""
|
|
|
|
|
2019-01-31 22:16:36 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def mitogen_ssh_compression(self):
|
|
|
|
"""
|
|
|
|
Whether SSH compression is enabled.
|
|
|
|
"""
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def extra_args(self):
|
|
|
|
"""
|
|
|
|
Connection-specific arguments.
|
|
|
|
"""
|
|
|
|
|
2019-05-26 11:06:14 +00:00
|
|
|
@abc.abstractmethod
|
|
|
|
def ansible_doas_exe(self):
|
|
|
|
"""
|
|
|
|
Value of "ansible_doas_exe" variable.
|
|
|
|
"""
|
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
|
|
|
|
class PlayContextSpec(Spec):
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
"""
|
2019-01-22 01:25:46 +00:00
|
|
|
PlayContextSpec takes almost all its information as-is from Ansible's
|
|
|
|
PlayContext. It is used for normal connections and delegate_to connections,
|
|
|
|
and should always be accurate.
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
"""
|
2020-03-05 00:05:29 +00:00
|
|
|
def __init__(self, connection, play_context, transport, inventory_name):
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
self._connection = connection
|
|
|
|
self._play_context = play_context
|
|
|
|
self._transport = transport
|
|
|
|
self._inventory_name = inventory_name
|
2020-01-30 23:44:20 +00:00
|
|
|
self._task_vars = self._connection._get_task_vars()
|
|
|
|
# used to run interpreter discovery
|
2020-03-05 00:05:29 +00:00
|
|
|
self._action = connection._action
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def transport(self):
|
|
|
|
return self._transport
|
|
|
|
|
|
|
|
def inventory_name(self):
|
|
|
|
return self._inventory_name
|
|
|
|
|
|
|
|
def remote_addr(self):
|
|
|
|
return self._play_context.remote_addr
|
|
|
|
|
|
|
|
def remote_user(self):
|
|
|
|
return self._play_context.remote_user
|
|
|
|
|
|
|
|
def become(self):
|
|
|
|
return self._play_context.become
|
|
|
|
|
|
|
|
def become_method(self):
|
|
|
|
return self._play_context.become_method
|
|
|
|
|
|
|
|
def become_user(self):
|
|
|
|
return self._play_context.become_user
|
|
|
|
|
|
|
|
def become_pass(self):
|
2019-01-22 01:25:46 +00:00
|
|
|
return optional_secret(self._play_context.become_pass)
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def password(self):
|
2019-01-22 01:25:46 +00:00
|
|
|
return optional_secret(self._play_context.password)
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def port(self):
|
|
|
|
return self._play_context.port
|
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
def python_path(self, rediscover_python=False):
|
2019-02-12 00:11:43 +00:00
|
|
|
s = self._connection.get_task_var('ansible_python_interpreter')
|
|
|
|
# #511, #536: executor/module_common.py::_get_shebang() hard-wires
|
|
|
|
# "/usr/bin/python" as the default interpreter path if no other
|
|
|
|
# interpreter is specified.
|
2020-01-30 23:44:20 +00:00
|
|
|
return parse_python_path(
|
2020-03-03 22:50:50 +00:00
|
|
|
s,
|
2020-01-30 23:44:20 +00:00
|
|
|
task_vars=self._task_vars,
|
2020-03-03 22:50:50 +00:00
|
|
|
action=self._action,
|
|
|
|
rediscover_python=rediscover_python)
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def private_key_file(self):
|
|
|
|
return self._play_context.private_key_file
|
|
|
|
|
|
|
|
def ssh_executable(self):
|
2021-11-10 22:34:32 +00:00
|
|
|
return C.config.get_config_value("ssh_executable", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {}))
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def timeout(self):
|
|
|
|
return self._play_context.timeout
|
|
|
|
|
|
|
|
def ansible_ssh_timeout(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._connection.get_task_var('ansible_timeout') or
|
|
|
|
self._connection.get_task_var('ansible_ssh_timeout') or
|
|
|
|
self.timeout()
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def ssh_args(self):
|
|
|
|
return [
|
|
|
|
mitogen.core.to_text(term)
|
|
|
|
for s in (
|
2021-11-10 22:34:32 +00:00
|
|
|
C.config.get_config_value("ssh_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})),
|
|
|
|
C.config.get_config_value("ssh_common_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})),
|
|
|
|
C.config.get_config_value("ssh_extra_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {}))
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
for term in ansible.utils.shlex.shlex_split(s or '')
|
|
|
|
]
|
|
|
|
|
|
|
|
def become_exe(self):
|
2019-05-26 11:06:14 +00:00
|
|
|
# In Ansible 2.8, PlayContext.become_exe always has a default value due
|
|
|
|
# to the new options mechanism. Previously it was only set if a value
|
|
|
|
# ("somewhere") had been specified for the task.
|
|
|
|
# For consistency in the tests, here we make older Ansibles behave like
|
|
|
|
# newer Ansibles.
|
|
|
|
exe = self._play_context.become_exe
|
|
|
|
if exe is None and self._play_context.become_method == 'sudo':
|
|
|
|
exe = 'sudo'
|
|
|
|
return exe
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def sudo_args(self):
|
|
|
|
return [
|
|
|
|
mitogen.core.to_text(term)
|
2019-01-27 04:44:24 +00:00
|
|
|
for term in ansible.utils.shlex.shlex_split(
|
|
|
|
first_true((
|
|
|
|
self._play_context.become_flags,
|
2019-05-26 11:06:14 +00:00
|
|
|
# Ansible <=2.7.
|
|
|
|
getattr(self._play_context, 'sudo_flags', ''),
|
|
|
|
# Ansible <=2.3.
|
2019-01-27 04:44:24 +00:00
|
|
|
getattr(C, 'DEFAULT_BECOME_FLAGS', ''),
|
|
|
|
getattr(C, 'DEFAULT_SUDO_FLAGS', '')
|
|
|
|
), default='')
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
def mitogen_via(self):
|
|
|
|
return self._connection.get_task_var('mitogen_via')
|
|
|
|
|
|
|
|
def mitogen_kind(self):
|
|
|
|
return self._connection.get_task_var('mitogen_kind')
|
|
|
|
|
2019-04-16 20:15:31 +00:00
|
|
|
def mitogen_mask_remote_name(self):
|
|
|
|
return self._connection.get_task_var('mitogen_mask_remote_name')
|
|
|
|
|
2019-06-08 23:06:30 +00:00
|
|
|
def mitogen_buildah_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_buildah_path')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def mitogen_docker_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_docker_path')
|
|
|
|
|
|
|
|
def mitogen_kubectl_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_kubectl_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_lxc_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_attach_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_lxc_attach_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_info_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_lxc_info_path')
|
|
|
|
|
2019-06-03 16:40:58 +00:00
|
|
|
def mitogen_ssh_keepalive_interval(self):
|
|
|
|
return self._connection.get_task_var('mitogen_ssh_keepalive_interval')
|
|
|
|
|
|
|
|
def mitogen_ssh_keepalive_count(self):
|
|
|
|
return self._connection.get_task_var('mitogen_ssh_keepalive_count')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def mitogen_machinectl_path(self):
|
|
|
|
return self._connection.get_task_var('mitogen_machinectl_path')
|
|
|
|
|
|
|
|
def mitogen_ssh_debug_level(self):
|
|
|
|
return self._connection.get_task_var('mitogen_ssh_debug_level')
|
|
|
|
|
2019-01-31 22:16:36 +00:00
|
|
|
def mitogen_ssh_compression(self):
|
|
|
|
return self._connection.get_task_var('mitogen_ssh_compression')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def extra_args(self):
|
|
|
|
return self._connection.get_extra_args()
|
|
|
|
|
2019-05-26 11:06:14 +00:00
|
|
|
def ansible_doas_exe(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._connection.get_task_var('ansible_doas_exe') or
|
|
|
|
os.environ.get('ANSIBLE_DOAS_EXE')
|
2019-05-26 11:06:14 +00:00
|
|
|
)
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
2019-01-22 01:25:46 +00:00
|
|
|
class MitogenViaSpec(Spec):
|
|
|
|
"""
|
|
|
|
MitogenViaSpec takes most of its information from the HostVars of the
|
|
|
|
running task. HostVars is a lightweight wrapper around VariableManager, so
|
|
|
|
it is better to say that VariableManager.get_vars() is the ultimate source
|
|
|
|
of MitogenViaSpec's information.
|
|
|
|
|
|
|
|
Due to this, mitogen_via= hosts must have all their configuration
|
|
|
|
information represented as host and group variables. We cannot use any
|
|
|
|
per-task configuration, as all that data belongs to the real target host.
|
|
|
|
|
|
|
|
Ansible uses all kinds of strange historical logic for calculating
|
|
|
|
variables, including making their precedence configurable. MitogenViaSpec
|
|
|
|
must ultimately reimplement all of that logic. It is likely that if you are
|
|
|
|
having a configruation problem with connection delegation, the answer to
|
|
|
|
your problem lies in the method implementations below!
|
|
|
|
"""
|
2020-01-30 23:44:20 +00:00
|
|
|
def __init__(self, inventory_name, host_vars, task_vars, become_method, become_user,
|
|
|
|
play_context, action):
|
2019-02-12 14:33:36 +00:00
|
|
|
"""
|
|
|
|
:param str inventory_name:
|
|
|
|
The inventory name of the intermediary machine, i.e. not the target
|
|
|
|
machine.
|
|
|
|
:param dict host_vars:
|
|
|
|
The HostVars magic dictionary provided by Ansible in task_vars.
|
2020-02-01 01:37:26 +00:00
|
|
|
:param dict task_vars:
|
|
|
|
Task vars provided by Ansible.
|
2019-02-12 14:33:36 +00:00
|
|
|
:param str become_method:
|
|
|
|
If the mitogen_via= spec included a become method, the method it
|
|
|
|
specifies.
|
|
|
|
:param str become_user:
|
|
|
|
If the mitogen_via= spec included a become user, the user it
|
|
|
|
specifies.
|
|
|
|
:param PlayContext play_context:
|
|
|
|
For some global values **only**, the PlayContext used to describe
|
|
|
|
the real target machine. Values from this object are **strictly
|
|
|
|
restricted** to values that are Ansible-global, e.g. the passwords
|
|
|
|
specified interactively.
|
2020-01-30 23:44:20 +00:00
|
|
|
:param ActionModuleMixin action:
|
|
|
|
Backref to the ActionModuleMixin required for ansible interpreter discovery
|
2019-02-12 14:33:36 +00:00
|
|
|
"""
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
self._inventory_name = inventory_name
|
|
|
|
self._host_vars = host_vars
|
2020-01-30 23:44:20 +00:00
|
|
|
self._task_vars = task_vars
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
self._become_method = become_method
|
|
|
|
self._become_user = become_user
|
2019-02-12 14:33:36 +00:00
|
|
|
# Dangerous! You may find a variable you want in this object, but it's
|
|
|
|
# almost certainly for the wrong machine!
|
|
|
|
self._dangerous_play_context = play_context
|
2020-01-30 23:44:20 +00:00
|
|
|
self._action = action
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def transport(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_connection') or
|
|
|
|
C.DEFAULT_TRANSPORT
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def inventory_name(self):
|
|
|
|
return self._inventory_name
|
|
|
|
|
|
|
|
def remote_addr(self):
|
2019-02-12 14:33:36 +00:00
|
|
|
# play_context.py::MAGIC_VARIABLE_MAPPING
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_ssh_host') or
|
|
|
|
self._host_vars.get('ansible_host') or
|
|
|
|
self._inventory_name
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def remote_user(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_ssh_user') or
|
|
|
|
self._host_vars.get('ansible_user') or
|
|
|
|
C.DEFAULT_REMOTE_USER
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def become(self):
|
|
|
|
return bool(self._become_user)
|
|
|
|
|
|
|
|
def become_method(self):
|
2019-02-12 14:33:36 +00:00
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._become_method or
|
|
|
|
self._host_vars.get('ansible_become_method') or
|
|
|
|
C.DEFAULT_BECOME_METHOD
|
2019-02-12 14:33:36 +00:00
|
|
|
)
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def become_user(self):
|
|
|
|
return self._become_user
|
|
|
|
|
|
|
|
def become_pass(self):
|
2019-01-22 01:25:46 +00:00
|
|
|
return optional_secret(
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_become_password') or
|
|
|
|
self._host_vars.get('ansible_become_pass')
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def password(self):
|
2019-01-22 01:25:46 +00:00
|
|
|
return optional_secret(
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_ssh_pass') or
|
|
|
|
self._host_vars.get('ansible_password')
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def port(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_ssh_port') or
|
|
|
|
self._host_vars.get('ansible_port') or
|
|
|
|
C.DEFAULT_REMOTE_PORT
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
2020-03-03 22:50:50 +00:00
|
|
|
def python_path(self, rediscover_python=False):
|
2019-02-12 00:11:43 +00:00
|
|
|
s = self._host_vars.get('ansible_python_interpreter')
|
|
|
|
# #511, #536: executor/module_common.py::_get_shebang() hard-wires
|
|
|
|
# "/usr/bin/python" as the default interpreter path if no other
|
|
|
|
# interpreter is specified.
|
2020-01-30 23:44:20 +00:00
|
|
|
return parse_python_path(
|
2020-03-03 22:50:50 +00:00
|
|
|
s,
|
2020-01-30 23:44:20 +00:00
|
|
|
task_vars=self._task_vars,
|
2020-03-03 22:50:50 +00:00
|
|
|
action=self._action,
|
|
|
|
rediscover_python=rediscover_python)
|
2019-02-12 00:11:43 +00:00
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def private_key_file(self):
|
|
|
|
# TODO: must come from PlayContext too.
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_ssh_private_key_file') or
|
|
|
|
self._host_vars.get('ansible_private_key_file') or
|
|
|
|
C.DEFAULT_PRIVATE_KEY_FILE
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def ssh_executable(self):
|
2021-11-10 22:34:32 +00:00
|
|
|
return C.config.get_config_value("ssh_executable", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {}))
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
|
|
|
|
def timeout(self):
|
|
|
|
# TODO: must come from PlayContext too.
|
|
|
|
return C.DEFAULT_TIMEOUT
|
|
|
|
|
|
|
|
def ansible_ssh_timeout(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_timeout') or
|
|
|
|
self._host_vars.get('ansible_ssh_timeout') or
|
|
|
|
self.timeout()
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def ssh_args(self):
|
|
|
|
return [
|
|
|
|
mitogen.core.to_text(term)
|
|
|
|
for s in (
|
2021-11-10 22:34:32 +00:00
|
|
|
C.config.get_config_value("ssh_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})),
|
|
|
|
C.config.get_config_value("ssh_common_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})),
|
|
|
|
C.config.get_config_value("ssh_extra_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {}))
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
for term in ansible.utils.shlex.shlex_split(s)
|
|
|
|
if s
|
|
|
|
]
|
|
|
|
|
|
|
|
def become_exe(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_become_exe') or
|
|
|
|
C.DEFAULT_BECOME_EXE
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def sudo_args(self):
|
|
|
|
return [
|
|
|
|
mitogen.core.to_text(term)
|
|
|
|
for s in (
|
|
|
|
self._host_vars.get('ansible_sudo_flags') or '',
|
|
|
|
self._host_vars.get('ansible_become_flags') or '',
|
|
|
|
)
|
|
|
|
for term in ansible.utils.shlex.shlex_split(s)
|
|
|
|
]
|
|
|
|
|
|
|
|
def mitogen_via(self):
|
|
|
|
return self._host_vars.get('mitogen_via')
|
|
|
|
|
|
|
|
def mitogen_kind(self):
|
|
|
|
return self._host_vars.get('mitogen_kind')
|
|
|
|
|
2019-04-16 20:15:31 +00:00
|
|
|
def mitogen_mask_remote_name(self):
|
|
|
|
return self._host_vars.get('mitogen_mask_remote_name')
|
|
|
|
|
2019-06-08 23:06:30 +00:00
|
|
|
def mitogen_buildah_path(self):
|
|
|
|
return self._host_vars.get('mitogen_buildah_path')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def mitogen_docker_path(self):
|
|
|
|
return self._host_vars.get('mitogen_docker_path')
|
|
|
|
|
|
|
|
def mitogen_kubectl_path(self):
|
|
|
|
return self._host_vars.get('mitogen_kubectl_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_path(self):
|
|
|
|
return self.host_vars.get('mitogen_lxc_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_attach_path(self):
|
|
|
|
return self._host_vars.get('mitogen_lxc_attach_path')
|
|
|
|
|
|
|
|
def mitogen_lxc_info_path(self):
|
|
|
|
return self._host_vars.get('mitogen_lxc_info_path')
|
|
|
|
|
2019-06-03 16:40:58 +00:00
|
|
|
def mitogen_ssh_keepalive_interval(self):
|
|
|
|
return self._host_vars.get('mitogen_ssh_keepalive_interval')
|
|
|
|
|
|
|
|
def mitogen_ssh_keepalive_count(self):
|
|
|
|
return self._host_vars.get('mitogen_ssh_keepalive_count')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def mitogen_machinectl_path(self):
|
|
|
|
return self._host_vars.get('mitogen_machinectl_path')
|
|
|
|
|
|
|
|
def mitogen_ssh_debug_level(self):
|
|
|
|
return self._host_vars.get('mitogen_ssh_debug_level')
|
|
|
|
|
2019-01-31 22:16:36 +00:00
|
|
|
def mitogen_ssh_compression(self):
|
|
|
|
return self._host_vars.get('mitogen_ssh_compression')
|
|
|
|
|
issue #251, #412, #434: fix connection configuration brainwrong
This refactors connection.py to pull the two huge dict-building
functions out into new transport_transport_config.PlayContextSpec and
MitogenViaSpec classes, leaving a lot more room to breath in both files
to figure out exactly how connection configuration should work.
The changes made in 1f21a30 / 3d58832 are updated or completely removed,
the original change was misguided, in a bid to fix connection delegation
taking variables from the wrong place when delegate_to was active.
The Python path no longer defaults to '/usr/bin/python', this does not
appear to be Ansible's normal behaviour. This has changed several times,
so it may have to change again, and it may cause breakage after release.
Connection delegation respects the c.DEFAULT_REMOTE_USER whereas the
previous version simply tried to fetch whatever was in the
'ansible_user' hostvar. Many more connection delegation variables closer
match vanilla's handling, but this still requires more work. Some of the
variables need access to the command line, and upstream are in the
process of changing all that stuff around.
2019-01-22 00:40:32 +00:00
|
|
|
def extra_args(self):
|
|
|
|
return [] # TODO
|
2019-05-26 11:06:14 +00:00
|
|
|
|
|
|
|
def ansible_doas_exe(self):
|
|
|
|
return (
|
2020-01-30 02:55:35 +00:00
|
|
|
self._host_vars.get('ansible_doas_exe') or
|
|
|
|
os.environ.get('ANSIBLE_DOAS_EXE')
|
2019-05-26 11:06:14 +00:00
|
|
|
)
|