Skip to content

Commit 8cda5f5

Browse files
authored
Merge pull request #933 from moreati/ansible6
Ansible 6 support
2 parents e36bbde + f150387 commit 8cda5f5

File tree

9 files changed

+29
-79
lines changed

9 files changed

+29
-79
lines changed

.ci/azure-pipelines.yml

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ jobs:
3333
Loc_27_210:
3434
python.version: '2.7'
3535
tox.env: py27-mode_localhost-ansible2.10
36-
Loc_27_3:
37-
python.version: '2.7'
38-
tox.env: py27-mode_localhost-ansible3
3936
Loc_27_4:
4037
python.version: '2.7'
4138
tox.env: py27-mode_localhost-ansible4
@@ -46,11 +43,6 @@ jobs:
4643
tox.env: py27-mode_localhost-ansible2.10
4744
STRATEGY: linear
4845
ANSIBLE_SKIP_TAGS: resource_intensive
49-
Van_27_3:
50-
python.version: '2.7'
51-
tox.env: py27-mode_localhost-ansible3
52-
STRATEGY: linear
53-
ANSIBLE_SKIP_TAGS: resource_intensive
5446
Van_27_4:
5547
python.version: '2.7'
5648
tox.env: py27-mode_localhost-ansible4
@@ -79,8 +71,6 @@ jobs:
7971
# TODO: test python3, python3 tests are broken
8072
Loc_27_210:
8173
tox.env: py27-mode_localhost-ansible2.10
82-
Loc_27_3:
83-
tox.env: py27-mode_localhost-ansible3
8474
Loc_27_4:
8575
tox.env: py27-mode_localhost-ansible4
8676

@@ -89,10 +79,6 @@ jobs:
8979
tox.env: py27-mode_localhost-ansible2.10
9080
STRATEGY: linear
9181
ANSIBLE_SKIP_TAGS: resource_intensive
92-
Van_27_3:
93-
tox.env: py27-mode_localhost-ansible3
94-
STRATEGY: linear
95-
ANSIBLE_SKIP_TAGS: resource_intensive
9682
Van_27_4:
9783
tox.env: py27-mode_localhost-ansible4
9884
STRATEGY: linear
@@ -190,59 +176,16 @@ jobs:
190176
python.version: '3.10'
191177
tox.env: py310-mode_mitogen-distro_ubuntu2004
192178

193-
#DebOps_2460_27_27:
194-
#python.version: '2.7'
195-
#MODE: debops_common
196-
#VER: 2.4.6.0
197-
198-
#DebOps_262_36_27:
199-
#python.version: '3.6'
200-
#MODE: debops_common
201-
#VER: 2.6.2
202-
203-
#Ansible_2460_26:
204-
#python.version: '2.7'
205-
#MODE: ansible
206-
#VER: 2.4.6.0
207-
208-
#Ansible_262_26:
209-
#python.version: '2.7'
210-
#MODE: ansible
211-
#VER: 2.6.2
212-
213-
#Ansible_2460_36:
214-
#python.version: '3.6'
215-
#MODE: ansible
216-
#VER: 2.4.6.0
217-
218-
#Ansible_262_36:
219-
#python.version: '3.6'
220-
#MODE: ansible
221-
#VER: 2.6.2
222-
223-
#Vanilla_262_27:
224-
#python.version: '2.7'
225-
#MODE: ansible
226-
#VER: 2.6.2
227-
#DISTROS: debian
228-
#STRATEGY: linear
229-
230179
Ans_27_210:
231180
python.version: '2.7'
232181
tox.env: py27-mode_ansible-ansible2.10
233-
Ans_27_3:
234-
python.version: '2.7'
235-
tox.env: py27-mode_ansible-ansible3
236182
Ans_27_4:
237183
python.version: '2.7'
238184
tox.env: py27-mode_ansible-ansible4
239185

240186
Ans_36_210:
241187
python.version: '3.6'
242188
tox.env: py36-mode_ansible-ansible2.10
243-
Ans_36_3:
244-
python.version: '3.6'
245-
tox.env: py36-mode_ansible-ansible3
246189
Ans_36_4:
247190
python.version: '3.6'
248191
tox.env: py36-mode_ansible-ansible4
@@ -259,3 +202,6 @@ jobs:
259202
Ans_310_5:
260203
python.version: '3.10'
261204
tox.env: py310-mode_ansible-ansible5
205+
Ans_310_6:
206+
python.version: '3.10'
207+
tox.env: py310-mode_ansible-ansible6

ansible_mitogen/loaders.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
__all__ = [
4141
'action_loader',
42+
'become_loader',
4243
'connection_loader',
4344
'module_loader',
4445
'module_utils_loader',
@@ -48,7 +49,7 @@
4849

4950

5051
ANSIBLE_VERSION_MIN = (2, 10)
51-
ANSIBLE_VERSION_MAX = (2, 12)
52+
ANSIBLE_VERSION_MAX = (2, 13)
5253

5354
NEW_VERSION_MSG = (
5455
"Your Ansible version (%s) is too recent. The most recent version\n"
@@ -90,6 +91,7 @@ def assert_supported_release():
9091

9192

9293
from ansible.plugins.loader import action_loader
94+
from ansible.plugins.loader import become_loader
9395
from ansible.plugins.loader import connection_loader
9496
from ansible.plugins.loader import module_loader
9597
from ansible.plugins.loader import module_utils_loader

ansible_mitogen/transport_config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
except ImportError:
8080
from ansible.vars.unsafe_proxy import AnsibleUnsafeText
8181

82+
import ansible_mitogen.loaders
8283
import mitogen.core
8384

8485

@@ -435,7 +436,10 @@ def become_user(self):
435436
return self._play_context.become_user
436437

437438
def become_pass(self):
438-
return optional_secret(self._play_context.become_pass)
439+
become_method = self.become_method()
440+
become_plugin = ansible_mitogen.loaders.become_loader.get(become_method)
441+
become_pass = become_plugin.get_option('become_pass', hostvars=self._task_vars)
442+
return optional_secret(become_pass)
439443

440444
def password(self):
441445
return optional_secret(self._play_context.password)
@@ -652,8 +656,8 @@ def become_user(self):
652656

653657
def become_pass(self):
654658
return optional_secret(
655-
self._host_vars.get('ansible_become_password') or
656-
self._host_vars.get('ansible_become_pass')
659+
self._host_vars.get('ansible_become_pass') or
660+
self._host_vars.get('ansible_become_password')
657661
)
658662

659663
def password(self):

docs/ansible_detailed.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Noteworthy Differences
148148
* Mitogen 0.2.x supports Ansible 2.3-2.9; with Python 2.6, 2.7, or 3.6.
149149
Mitogen 0.3.1+ supports
150150
- Ansible 2.10, 3, and 4; with Python 2.7, or 3.6-3.10
151-
- Ansible 5; with Python 3.8-3.10
151+
- Ansible 5 and 6; with Python 3.8-3.10
152152
Verify your installation is running one of these versions by checking
153153
``ansible --version`` output.
154154

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ To avail of fixes in an unreleased version, please download a ZIP file
2020
v0.3.4.dev0
2121
-------------------
2222

23+
* :gh:issue:`929` Support Ansible 6 and ansible-core 2.13
2324
* :gh:issue:`832` Fix runtime error when using the ansible.builtin.dnf module multiple times
2425

2526
v0.3.3 (2022-06-03)

mitogen/master.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def find(self, fullname):
536536

537537
try:
538538
path = loader.get_filename(fullname)
539-
except (AttributeError, ImportError):
539+
except (AttributeError, ImportError, ValueError):
540540
# - get_filename() may throw ImportError if pkgutil.find_loader()
541541
# picks a "parent" package's loader for some crap that's been
542542
# stuffed in sys.modules, for example in the case of urllib3:

tests/ansible/hosts/transport_config.hosts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tc-become-user-set ansible_become_user=ansi-become-user
4747
tc-become-pass-unset
4848
tc-become-pass-password ansible_become_password=apassword
4949
tc-become-pass-pass ansible_become_pass=apass
50-
tc-become-pass-both ansible_become_password=a.b.c ansible_become_pass=c.b.a
50+
tc-become-pass-both ansible_become_pass=bpass ansible_become_password=bpassword
5151

5252
# port()
5353
tc-port-unset

tests/ansible/integration/transport_config/become_pass.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@
119119
fail_msg: out={{out}}
120120

121121

122-
123-
# ansible_become_pass & ansible_become_password set, password used to take precedence
124-
# but it's possible since https://github.com/ansible/ansible/pull/69629/files#r428376864, now it doesn't
125122
- hosts: tc-become-pass-both
126123
become: true
127124
tasks:
@@ -132,7 +129,9 @@
132129
- out.result|length == 2
133130
- out.result[0].method == "ssh"
134131
- out.result[1].method == "sudo"
135-
- out.result[1].kwargs.password == "c.b.a"
132+
# Ansible >= 2.10 builtin become plugins (e.g. sudo, su) give priority
133+
# to ansible_become_pass over ansible_become_password.
134+
- out.result[1].kwargs.password == "bpass"
136135
fail_msg: out={{out}}
137136

138137

@@ -147,6 +146,6 @@
147146
- out.result|length == 3
148147
- out.result[0].method == "ssh"
149148
- out.result[1].method == "sudo"
150-
- out.result[1].kwargs.password == "a.b.c"
149+
- out.result[1].kwargs.password == "bpass"
151150
- out.result[2].method == "ssh"
152151
fail_msg: out={{out}}

tox.ini

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
# ansible == 3.* ansible-base ~= 2.10.0
2727
# ansible == 4.* ansible-core ~= 2.11.0
2828
# ansible == 5.* ansible-core ~= 2.12.0
29+
# ansible == 6.* ansible-core ~= 2.13.0
2930

3031
# pip --no-python-version-warning
3132
# pip --disable-pip-version-check
@@ -36,7 +37,7 @@
3637
envlist =
3738
init,
3839
py{27,36}-mode_ansible-ansible{2.10,3,4},
39-
py{310}-mode_ansible-ansible{2.10,3,4,5},
40+
py{310}-mode_ansible-ansible{2.10,3,4,5,6},
4041
py{27,36,310}-mode_mitogen-distro_centos{6,7,8},
4142
py{27,36,310}-mode_mitogen-distro_debian{9,10,11},
4243
py{27,36,310}-mode_mitogen-distro_ubuntu{1604,1804,2004},
@@ -57,16 +58,11 @@ basepython =
5758
deps =
5859
-r{toxinidir}/tests/requirements.txt
5960
mode_ansible: -r{toxinidir}/tests/ansible/requirements.txt
60-
ansible2.3: ansible==2.3.3.0
61-
ansible2.4: ansible==2.4.6.0
62-
ansible2.8: ansible==2.8.3
63-
ansible2.9: ansible==2.9.6
64-
ansible2.10: ansible-base<2.10.14
65-
ansible2.10: ansible==2.10.0
66-
ansible3: ansible-base<2.10.14
61+
ansible2.10: ansible==2.10.7
6762
ansible3: ansible==3.4.0
68-
ansible4: ansible==4.8.0
69-
ansible5: ansible==5.0.1
63+
ansible4: ansible==4.10.0
64+
ansible5: ansible==5.8.0
65+
ansible6: ansible==6.0.0
7066
install_command =
7167
python -m pip --no-python-version-warning --disable-pip-version-check install {opts} {packages}
7268
commands_pre =
@@ -103,6 +99,8 @@ setenv =
10399
distro_ubuntu1804: DISTRO=ubuntu1804
104100
distro_ubuntu2004: DISTRO=ubuntu2004
105101
# Note the plural, only applicable to MODE=ansible
102+
# Ansible 6 (ansible-core 2.13) requires Python >= 2.7 or >= 3.5 on targets
103+
ansible6: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004
106104
distros_centos: DISTROS=centos6 centos7 centos8
107105
distros_centos5: DISTROS=centos5
108106
distros_centos6: DISTROS=centos6

0 commit comments

Comments
 (0)