Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
moreati committed Oct 13, 2024
1 parent 3b2b03b commit 5e7eeef
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 96 deletions.
51 changes: 2 additions & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- docs-master

env:
#ANSIBLE_VERBOSITY: 3
ANSIBLE_VERBOSITY: 3
#MITOGEN_LOG_LEVEL: DEBUG
MITOGEN_TEST_IMAGE_TEMPLATE: "ghcr.io/mitogen-hq/%(distro)s-test"

Expand All @@ -26,55 +26,14 @@ jobs:
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: Van_313_10
python_version: '3.13'
tox_env: py313-mode_ansible-ansible10-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
Expand Down Expand Up @@ -164,12 +123,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: Mito_27
tox_env: py27-mode_mitogen
- name: Mito_313
python_version: '3.13'
tox_env: py313-mode_mitogen

- name: Loc_27_210
tox_env: py27-mode_localhost-ansible2.10
- name: Loc_313_10
Expand Down
34 changes: 32 additions & 2 deletions ansible_mitogen/transport_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,41 @@ def __init__(self, connection, play_context, transport, inventory_name):
# used to run interpreter discovery
self._action = connection._action

def _become_option(self, name):
plugin = self._connection.become
try:
if name not in plugin._options:
value, _ = plugin.get_option_and_origin(
name, hostvars=self._task_vars,
#playcontext=self._play_context,
)
plugin.set_option(name, value)
return plugin._options.get(name)
except AttributeError as exc:
raise
LOG.error('become plugin=%r: %s', plugin, exc)
except KeyError:
raise
if name not in {'become_user', 'become_pass', 'become_flags', 'become_exe'}:
raise
LOG.error(
'Used PlayContext fallback for become plugin=%r, option=%r, connection=%r, transport=%r, action=%r',
plugin, name, self._connection, self._transport, self._action,
)
try:
return getattr(self._play_context, name)
except AttributeError:
LOG.error('PlayContext did not have attribute %r', name)
return None

def _connection_option(self, name):
try:
return self._connection.get_option(name, hostvars=self._task_vars)
except KeyError:
LOG.debug('Used PlayContext fallback for option=%r', name)
LOG.error(
'Used PlayContext fallback for connection plugin=%r, option=%r',
self._connection, name,
)
return getattr(self._play_context, name)

def transport(self):
Expand All @@ -443,7 +473,7 @@ def become_method(self):
return self._play_context.become_method

def become_user(self):
return self._play_context.become_user
return self._become_option('become_user')

def become_pass(self):
# become_pass is owned/provided by the active become plugin. However
Expand Down
2 changes: 0 additions & 2 deletions tests/ansible/all.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
- import_playbook: setup/all.yml
tags: setup
- import_playbook: regression/all.yml
tags: regression
- import_playbook: integration/all.yml
tags: integration
33 changes: 0 additions & 33 deletions tests/ansible/integration/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,7 @@
#
# 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
9 changes: 0 additions & 9 deletions tests/ansible/integration/connection/all.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
---

- import_playbook: become_same_user.yml
- import_playbook: disconnect_during_module.yml
- import_playbook: disconnect_resets_connection.yml
- import_playbook: exec_command.yml
- import_playbook: home_dir.yml
- import_playbook: put_large_file.yml
- import_playbook: put_small_file.yml
- import_playbook: reset.yml
- import_playbook: reset_become.yml
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ setenv =
NOCOVERAGE_ERASE = 1
NOCOVERAGE_REPORT = 1
PIP_CONSTRAINT={toxinidir}/tests/constraints.txt
ansible2.10: MITOGEN_TEST_DISTRO_SPECS=ubuntu2004
# Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets
ansible6: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004
ansible7: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004
ansible8: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004
# Ansible 9 (ansible-core 2.16) requires Python 2.7 or >= 3.6 on targets
ansible9: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1804 ubuntu2004
# Ansible 10 (ansible-core 2.17) requires Python >= 3.7 on targets
ansible10: MITOGEN_TEST_DISTRO_SPECS=debian10-py3 debian11-py3 ubuntu2004-py3
ansible10: MITOGEN_TEST_DISTRO_SPECS=ubuntu2004-py3
distros_centos: MITOGEN_TEST_DISTRO_SPECS=centos6 centos7 centos8
distros_centos5: MITOGEN_TEST_DISTRO_SPECS=centos5
distros_centos6: MITOGEN_TEST_DISTRO_SPECS=centos6
Expand Down

0 comments on commit 5e7eeef

Please sign in to comment.