Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #1204

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

WIP #1204

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: Ans_27_210
tox_env: py27-mode_ansible-ansible2.10
- name: Ans_27_4
tox_env: py27-mode_ansible-ansible4

- name: Ans_36_210
python_version: '3.6'
tox_env: py36-mode_ansible-ansible2.10
- name: Ans_36_4
python_version: '3.6'
tox_env: py36-mode_ansible-ansible4

- name: Ans_311_210
python_version: '3.11'
tox_env: py311-mode_ansible-ansible2.10
- name: Ans_311_3
python_version: '3.11'
tox_env: py311-mode_ansible-ansible3
- name: Ans_311_4
python_version: '3.11'
tox_env: py311-mode_ansible-ansible4
- name: Ans_311_5
python_version: '3.11'
tox_env: py311-mode_ansible-ansible5
- name: Ans_313_6
python_version: '3.13'
tox_env: py313-mode_ansible-ansible6
- name: Ans_313_7
python_version: '3.13'
tox_env: py313-mode_ansible-ansible7
- name: Ans_313_8
python_version: '3.13'
tox_env: py313-mode_ansible-ansible8
- name: Ans_313_9
python_version: '3.13'
tox_env: py313-mode_ansible-ansible9
- name: Ans_313_10
python_version: '3.13'
tox_env: py313-mode_ansible-ansible10
- name: Ans_313_11
python_version: '3.13'
tox_env: py313-mode_ansible-ansible11
Expand All @@ -71,15 +32,6 @@ jobs:
python_version: '3.13'
tox_env: py313-mode_ansible-ansible11-strategy_linear

- name: Mito_27
tox_env: py27-mode_mitogen
- name: Mito_36
python_version: '3.6'
tox_env: py36-mode_mitogen
- name: Mito_313
python_version: '3.13'
tox_env: py313-mode_mitogen

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down Expand Up @@ -171,12 +123,6 @@ jobs:
- name: Mito_313
tox_env: py313-mode_mitogen

- name: Loc_313_11
tox_env: py313-mode_localhost-ansible11

- name: Van_313_11
tox_env: py313-mode_localhost-ansible11-strategy_linear

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
7 changes: 4 additions & 3 deletions ansible_mitogen/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_task_var(self, key, default=None):
does not make sense to extract connection-related configuration for the
delegated-to machine from them.
"""
def _fetch_task_var(task_vars, key):
def _fetch_task_var(task_vars, key, default):
"""
Special helper func in case vars can be templated
"""
Expand All @@ -651,15 +651,16 @@ def _fetch_task_var(task_vars, key):
escape_backslashes=False
)
return val
return default

task_vars = self._get_task_vars()
if self.delegate_to_hostname is None:
return _fetch_task_var(task_vars, key)
return _fetch_task_var(task_vars, key, default)
else:
delegated_vars = task_vars['ansible_delegated_vars']
if self.delegate_to_hostname in delegated_vars:
task_vars = delegated_vars[self.delegate_to_hostname]
return _fetch_task_var(task_vars, key)
return _fetch_task_var(task_vars, key, default)

return default

Expand Down
15 changes: 14 additions & 1 deletion ansible_mitogen/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible.module_utils.six.moves import shlex_quote
from ansible.parsing.utils.jsonify import jsonify
from ansible.utils.display import Display

import mitogen.core
import mitogen.select
Expand All @@ -54,6 +55,8 @@
import ansible_mitogen.utils.unsafe


display = Display()

LOG = logging.getLogger(__name__)


Expand Down Expand Up @@ -107,10 +110,20 @@ def __init__(self, task, connection, *args, **kwargs):
self._rediscovered_python = False
# redeclaring interpreter discovery vars here in case running ansible < 2.8.0
self._discovered_interpreter_key = None
self._discovered_interpreter = False
self._discovered_interpreterr = False
self._discovery_deprecation_warnings = []
self._discovery_warnings = []

@property
def _discovered_interpreter(self):
return self._discovered_interpreterr

@_discovered_interpreter.setter
def _discovered_interpreter(self, value):
if value:
display.warning('%r %s' % (value, traceback.format_stack()), formatted=True)
self._discovered_interpreterr = value

def run(self, tmp=None, task_vars=None):
"""
Override run() to notify Connection of task-specific data, so it has a
Expand Down
7 changes: 6 additions & 1 deletion ansible_mitogen/transport_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ def port(self):
return self._connection_option('port')

def python_path(self, rediscover_python=False):
s = self._connection.get_task_var('ansible_python_interpreter')
s = self._connection.get_task_var('ansible_python_interpreter',
default=C.config.get_config_value('INTERPRETER_PYTHON',
variables=self._task_vars))
# #511, #536: executor/module_common.py::_get_shebang() hard-wires
# "/usr/bin/python" as the default interpreter path if no other
# interpreter is specified.
Expand Down Expand Up @@ -703,6 +705,9 @@ def port(self):

def python_path(self, rediscover_python=False):
s = self._host_vars.get('ansible_python_interpreter')
if s is None:
s = C.config.get_config_value('INTERPRETER_PYTHON',
variables=self._task_vars)
# #511, #536: executor/module_common.py::_get_shebang() hard-wires
# "/usr/bin/python" as the default interpreter path if no other
# interpreter is specified.
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ In progress (unreleased)
with `meta: reset_connection`
* :gh:issue:`1083` :mod:`ansible_mitogen`: Templated connection timeout
(e.g. ``ansible_timeout``).
* :gh:issue:`740` respect `interpreter_python` global configuration variable


v0.3.19 (2024-12-02)
Expand Down
4 changes: 0 additions & 4 deletions tests/ansible/all.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
- import_playbook: setup/all.yml
tags: setup
- import_playbook: regression/all.yml
tags: regression
- import_playbook: integration/all.yml
tags: integration
39 changes: 0 additions & 39 deletions tests/ansible/integration/all.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,2 @@

#
# This playbook imports all tests that are known to work at present.
#

- import_playbook: action/all.yml
tags: action
- import_playbook: async/all.yml
tags: async
- import_playbook: become/all.yml
tags: become
- import_playbook: connection/all.yml
tags: connection
- import_playbook: connection_delegation/all.yml
tags: connection_delegation
- import_playbook: connection_loader/all.yml
tags: connection_loader
- import_playbook: context_service/all.yml
tags: context_service
- import_playbook: glibc_caches/all.yml
tags: glibc_caches
- import_playbook: interpreter_discovery/all.yml
tags: interpreter_discovery
- import_playbook: local/all.yml
tags: local
- import_playbook: module_utils/all.yml
tags: module_utils
- import_playbook: playbook_semantics/all.yml
tags: playbook_semantics
- import_playbook: process/all.yml
tags: process
- import_playbook: runner/all.yml
tags: runner
- import_playbook: ssh/all.yml
tags: ssh
- import_playbook: strategy/all.yml
tags: strategy
- import_playbook: stub_connections/all.yml
tags: stub_connections
- import_playbook: transport_config/all.yml
tags: transport_config
7 changes: 0 additions & 7 deletions tests/ansible/integration/transport_config/all.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
- import_playbook: become_method.yml
- import_playbook: become_pass.yml
- import_playbook: become_user.yml
- import_playbook: become.yml
- import_playbook: host_key_checking.yml
- import_playbook: password.yml
- import_playbook: port.yml
- import_playbook: python_path.yml
- import_playbook: remote_addr.yml
- import_playbook: remote_user.yml
Expand Down
Loading