diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cc20f04a2..a2def400f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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" @@ -26,40 +26,7 @@ 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 @@ -67,14 +34,6 @@ jobs: 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 @@ -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 diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index a9f672099..d1490c486 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -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): @@ -437,13 +467,14 @@ def remote_user(self): return self._connection_option('remote_user') def become(self): - return self._play_context.become + # c.DEFAULT_BECOME: ini, env + return self._connection.become 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 diff --git a/tests/ansible/all.yml b/tests/ansible/all.yml index 7a3e70001..49a3d83a1 100644 --- a/tests/ansible/all.yml +++ b/tests/ansible/all.yml @@ -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 diff --git a/tests/ansible/integration/all.yml b/tests/ansible/integration/all.yml index ac196584e..700d55ad8 100644 --- a/tests/ansible/integration/all.yml +++ b/tests/ansible/integration/all.yml @@ -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 diff --git a/tests/ansible/integration/connection/all.yml b/tests/ansible/integration/connection/all.yml index b707b0eb1..cc9f9468a 100644 --- a/tests/ansible/integration/connection/all.yml +++ b/tests/ansible/integration/connection/all.yml @@ -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 diff --git a/tests/ansible/integration/connection/reset_become.yml b/tests/ansible/integration/connection/reset_become.yml index 2548df17f..ddf023513 100644 --- a/tests/ansible/integration/connection/reset_become.yml +++ b/tests/ansible/integration/connection/reset_become.yml @@ -30,33 +30,3 @@ fail_msg: | become_acct={{ become_acct }} login_acct={{ login_acct }} - - - name: reset the connection - meta: reset_connection - - - name: save new pid of the become acct - custom_python_detect_environment: - register: new_become_acct - - - name: ensure become_acct != new_become_acct - assert: - that: - - become_acct.pid != new_become_acct.pid - fail_msg: | - become_acct={{ become_acct }} - new_become_acct={{ new_become_acct }} - - - name: save new pid of login acct - become: false - custom_python_detect_environment: - register: new_login_acct - - - name: ensure login_acct != new_login_acct - assert: - that: - - login_acct.pid != new_login_acct.pid - fail_msg: | - login_acct={{ login_acct }} - new_login_acct={{ new_login_acct }} - tags: - - reset_become diff --git a/tox.ini b/tox.ini index 5afa7eb1c..240182d86 100644 --- a/tox.ini +++ b/tox.ini @@ -103,6 +103,7 @@ 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 @@ -110,7 +111,7 @@ setenv = # 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