Skip to content

Commit 6edd431

Browse files
committed
WIP
1 parent c481965 commit 6edd431

File tree

9 files changed

+67
-93
lines changed

9 files changed

+67
-93
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- docs-master
1010

1111
env:
12-
#ANSIBLE_VERBOSITY: 3
12+
ANSIBLE_VERBOSITY: 3
1313
#MITOGEN_LOG_LEVEL: DEBUG
1414
MITOGEN_TEST_IMAGE_TEMPLATE: "ghcr.io/mitogen-hq/%(distro)s-test"
1515

@@ -24,61 +24,9 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
include:
27-
- name: Ans_27_210
28-
tox_env: py27-mode_ansible-ansible2.10
29-
- name: Ans_27_4
30-
tox_env: py27-mode_ansible-ansible4
31-
3227
- name: Ans_36_210
3328
python_version: '3.6'
3429
tox_env: py36-mode_ansible-ansible2.10
35-
- name: Ans_36_4
36-
python_version: '3.6'
37-
tox_env: py36-mode_ansible-ansible4
38-
39-
- name: Ans_311_210
40-
python_version: '3.11'
41-
tox_env: py311-mode_ansible-ansible2.10
42-
- name: Ans_311_3
43-
python_version: '3.11'
44-
tox_env: py311-mode_ansible-ansible3
45-
- name: Ans_311_4
46-
python_version: '3.11'
47-
tox_env: py311-mode_ansible-ansible4
48-
- name: Ans_311_5
49-
python_version: '3.11'
50-
tox_env: py311-mode_ansible-ansible5
51-
- name: Ans_313_6
52-
python_version: '3.13'
53-
tox_env: py313-mode_ansible-ansible6
54-
- name: Ans_313_7
55-
python_version: '3.13'
56-
tox_env: py313-mode_ansible-ansible7
57-
- name: Ans_313_8
58-
python_version: '3.13'
59-
tox_env: py313-mode_ansible-ansible8
60-
- name: Ans_313_9
61-
python_version: '3.13'
62-
tox_env: py313-mode_ansible-ansible9
63-
- name: Ans_313_10
64-
python_version: '3.13'
65-
tox_env: py313-mode_ansible-ansible10
66-
- name: Ans_313_11
67-
python_version: '3.13'
68-
tox_env: py313-mode_ansible-ansible11
69-
70-
- name: Van_313_11
71-
python_version: '3.13'
72-
tox_env: py313-mode_ansible-ansible11-strategy_linear
73-
74-
- name: Mito_27
75-
tox_env: py27-mode_mitogen
76-
- name: Mito_36
77-
python_version: '3.6'
78-
tox_env: py36-mode_mitogen
79-
- name: Mito_313
80-
python_version: '3.13'
81-
tox_env: py313-mode_mitogen
8230

8331
steps:
8432
- uses: actions/checkout@v4
@@ -171,12 +119,6 @@ jobs:
171119
- name: Mito_313
172120
tox_env: py313-mode_mitogen
173121

174-
- name: Loc_313_11
175-
tox_env: py313-mode_localhost-ansible11
176-
177-
- name: Van_313_11
178-
tox_env: py313-mode_localhost-ansible11-strategy_linear
179-
180122
steps:
181123
- uses: actions/checkout@v4
182124
- uses: actions/setup-python@v5

ansible_mitogen/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
491491
#: Only sudo, su, and doas are supported for now.
492492
# Ansible ConnectionBase attribute, removed in Ansible >= 2.8
493493
become_methods = ['sudo', 'su', 'doas']
494+
become_methods += ['mitogen.builtin.%s' % s for s in become_methods]
494495

495496
#: Dict containing init_child() return value as recorded at startup by
496497
#: ContextService. Contains:

ansible_mitogen/mixins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ def _low_level_execute_command(self, cmd, sudoable=True, in_data=None,
483483
cmd, in_data, sudoable, mitogen_chdir=chdir,
484484
)
485485
# TODO: what exception is thrown?
486-
except:
486+
except BaseException as e:
487+
LOG.warning(e)
487488
# we've reached the last python attempted and failed
488489
if possible_python == possible_pythons[-1]:
489490
raise

ansible_mitogen/services.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def get(self, stack):
477477
"""
478478
via = None
479479
for spec in stack:
480+
LOG.info('trying spec=%r', spec)
480481
try:
481482
result = self._wait_or_start(spec, via=via).get()
482483
if isinstance(result, tuple): # exc_info()
@@ -497,6 +498,7 @@ def get(self, stack):
497498
'msg': str(e),
498499
}
499500

501+
LOG.info('found spec=%r, via=%r -> result=%r', spec, via, result)
500502
return result
501503

502504

ansible_mitogen/transport_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ def __init__(self, connection, play_context, transport, inventory_name):
424424

425425
def _become_option(self, name):
426426
plugin = self._connection.become
427+
if not plugin:
428+
raise ValueError('Become option %s unavailable from %r' % (name, plugin))
427429
try:
428430
return plugin.get_option(name, self._task_vars, self._play_context)
429431
except AttributeError:

tests/ansible/all.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22
tags: setup
33
- import_playbook: regression/all.yml
44
tags: regression
5-
- import_playbook: integration/all.yml
6-
tags: integration

tests/ansible/regression/all.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
- import_playbook: issue_109__target_has_old_ansible_installed.yml
2-
- import_playbook: issue_113__duplicate_module_imports.yml
3-
- import_playbook: issue_118__script_not_marked_exec.yml
4-
- import_playbook: issue_122__environment_difference.yml
5-
- import_playbook: issue_140__thread_pileup.yml
6-
- import_playbook: issue_152__local_action_wrong_interpreter.yml
7-
- import_playbook: issue_152__virtualenv_python_fails.yml
8-
- import_playbook: issue_154__module_state_leaks.yml
9-
- import_playbook: issue_177__copy_module_failing.yml
10-
- import_playbook: issue_332_ansiblemoduleerror_first_occurrence.yml
11-
- import_playbook: issue_558_unarchive_failed.yml
12-
- import_playbook: issue_590__sys_modules_crap.yml
13-
- import_playbook: issue_591__setuptools_cwd_crash.yml
14-
- import_playbook: issue_615__streaming_transfer.yml
15-
- import_playbook: issue_655__wait_for_connection_error.yml
16-
- import_playbook: issue_766__get_with_context.yml
17-
- import_playbook: issue_776__load_plugins_called_twice.yml
18-
- import_playbook: issue_952__ask_become_pass.yml
19-
- import_playbook: issue_1066__add_host__host_key_checking.yml
20-
- import_playbook: issue_1079__wait_for_connection_timeout.yml
21-
- import_playbook: issue_1087__template_streamerror.yml
221
- import_playbook: issue_1232__fully_qualified_names_become_method.yml
Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,71 @@
1-
- name: regression/issue_1232__fully_qualified_names_become_method.yml (1/2)
1+
- name: regression/issue_1232__fully_qualified_names_become_method.yml (1/3)
22
hosts: test-targets
33
become_method: ansible.builtin.sudo
44
tasks:
5-
- name: Run a shell command with sudo root
6-
vars:
7-
ansible_become_pass: rootpassword
8-
ansible.builtin.command: whoami
5+
- name: Test FQCN sudo, passwordless
96
become: true
107
become_user: root
8+
command:
9+
cmd: whoami
10+
register: fqcn_sudo_passwordless_whoami
11+
changed_when: false
12+
13+
- assert:
14+
that:
15+
- fqcn_sudo_passwordless_whoami.stdout == 'root'
16+
fail_msg: |
17+
fqcn_sudo_passwordless_whoami={{ fqcn_sudo_passwordless_whoami }}
18+
tags:
19+
- sudo
1120

12-
- name: regression/issue_1232__fully_qualified_names_become_method.yml (2/2)
21+
- name: regression/issue_1232__fully_qualified_names_become_method.yml (2/3)
1322
hosts: test-targets
14-
become_method: ansible.builtin.su
23+
become_method: ansible.builtin.sudo
1524
tasks:
16-
- name: Run a shell command with su mitogen__user1
25+
- name: Test FQCN sudo, password required
26+
become: true
27+
become_user: mitogen__pw_required
1728
vars:
18-
ansible_become_pass: user1_password
29+
ansible_become_pass: pw_required_password
30+
command:
31+
cmd: whoami
32+
register: fqcn_sudo_password_whoami
33+
changed_when: false
1934
when:
2035
- become_unpriv_available
21-
ansible.builtin.command: whoami
36+
37+
- assert:
38+
that:
39+
- fqcn_sudo_password_whoami.stdout == 'mitogen__pw_required'
40+
fail_msg: |
41+
fqcn_sudo_password_whoami={{ fqcn_sudo_password_whoami }}
42+
when:
43+
- become_unpriv_available
44+
tags:
45+
- sudo
46+
47+
- name: regression/issue_1232__fully_qualified_names_become_method.yml (3/3)
48+
hosts: test-targets
49+
become_method: ansible.builtin.su
50+
tasks:
51+
- name: Test FQCN su, password required
2252
become: true
2353
become_user: mitogen__user1
54+
vars:
55+
ansible_become_pass: user1_password
56+
command:
57+
cmd: whoami
58+
register: fqcn_su_password_whoami
59+
changed_when: false
60+
when:
61+
- become_unpriv_available
62+
63+
- assert:
64+
that:
65+
- fqcn_su_password_whoami.stdout == 'mitogen__user1'
66+
fail_msg: |
67+
fqcn_su_password_whoami={{ fqcn_su_password_whoami }}
68+
when:
69+
- become_unpriv_available
70+
tags:
71+
- su

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ setenv =
107107
PIP_CONSTRAINT={toxinidir}/tests/constraints.txt
108108
# Print warning on the first occurence at each module:linenno in Mitogen. Available Python 2.7, 3.2+.
109109
PYTHONWARNINGS=default:::ansible_mitogen,default:::mitogen
110+
MITOGEN_TEST_DISTRO_SPECS=centos7
110111
# Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets
111112
ansible6: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004
112113
ansible7: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004

0 commit comments

Comments
 (0)