Closed moreati closed 1 month ago
That was unexpected. The new tests failed across the board https://dev.azure.com/mitogen-hq/mitogen/_build/results?buildId=908, e.g.
TASK [ansible_ssh_password ] ***************************************************
Wednesday 04 September 2024 10:49:43 +0000 (0:00:00.105) 0:07:41.566 ***
fatal: [target-centos6-1]: UNREACHABLE! => changed=false
msg: SSH password is incorrect
unreachable: true
That was unexpected. The new tests failed across the board
This is probably because ansible_password
, and ansible_ssh_pass
have legacy support in Ansible. THey predate the modern plugin variables options mechanism that ansible_ssh_password
is exposed through, and that Mitogen doesn't properly use (if at all). There are probably existing Mitogen issues and or PRs that touch on this.
See
ansible.constants.COMMON_CONNECTION_VARS
?ansible.constants.MAGIC_VARIABLE_MAPPING
ansible.playbook.play_context.RESET_VARS
?Survey of attributes/expressions currently used
self._play_context.<thing>
become_plugin.get_option('<thing>', playcontext=self._play_context)
self._connection.get_task_var('ansible_<thing>')
C.config.get_config_value("<thing>", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {}))
C.config.get_config_value("<thing>", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("hostvars", {}).get(self._inventory_name, {}))
Notes to self
self._task_vars
intialiased at instantiation, vs self._connection.get_task_var()
within individual methodsself._task_vars.get('vars')
vs self._task_vars.get('hostvars')
New plugins should define options:
in the DOCUMENTATION
string of their Python module.
Callback and connection plugins have declared configuration requirements this way since Ansible version 2.4; most plugin types now do the same.
To access the configuration settings in your plugin, use
self.get_option(<option_name>)
. [...] Become, callback, connection and shell plugins are guaranteed to have the engine callset_options()
. [...] Vars plugin settings are populated when first accessed (using theself.get_option()
orself.get_options()
method.
From https://docs.ansible.com/ansible/10/dev_guide/developing_plugins.html#vars-plugins
Playbook constructs like ‘host_vars’ and ‘group_vars’ work using vars plugins.
Most of the work now happens in the get_vars method which is called from the VariableManager when needed.
/AzurePipelines run
After a lot of experimentation I think ansible.plugins.AnsiblePlugin.get_option()
can be a basis for replacing the variety of techniques in ansible_mitogen.transport_config.PlayContextSpec()
et al. Open questions
...get_option(..., hostvars=tasks_vars)
how expensive is it to provide task_vars every time?HostVars
) in the Ansible code base?ansible_mitogen.transport_config.MitogenViaSpec()
be updated/treated?ansible_mitogen.plugins.*
populate DOCUMENTATION
options?At the moment it requires
...get_option(..., hostvars=tasks_vars)
how expensive is it to provide task_vars every time?
PlayContextSpec.__init__()
already calls Connection._get_task_vars()
, so there is no additional cost.
How should
ansible_mitogen.plugins.*
populateDOCUMENTATION
options?
This works for the ssh plugin atleast, but it's ugly as sin.
# This specifically has to be from ... import ..., to avoid some *waves hands* post import shuffling
# that ansible does to the sys.modules entry of ansible.plugins.ssh that results in AtrributeError
from ansible.plugins.connection.ssh import DOCUMENTATION as _ansible_ssh_DOCUMENTATION
DOCUMENTATION = """
name: ...
...
options:
""" + _ansible_ssh_DOCUMENTATION.partition('options:\n')[2]
It doesn't handle
connection_pipelining
fragment this may not matter. That was a hell of a journey. Some washup items
What is the difference between task vars, and host vars (HostVars) in the Ansible code base?
I think
hostvars
when they mean task vars.How should ansible_mitogen.transport_config.MitogenViaSpec() be updated/treated?
Worth it's own issue, #1135.
Based on original PR #1107 by @madsi1m, which I accidentally clobbered (see https://github.com/mitogen-hq/mitogen/pull/1107#issuecomment-2328528596).
Fixes #1106.