Skip to content

Commit 021d712

Browse files
authored
Merge pull request #1316 from moreati/release-v0.3.25
Release v0.3.25
2 parents 4f213ab + 536ab7d commit 021d712

File tree

65 files changed

+710
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+710
-110
lines changed

.ci/install_sshpass

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
VERSION="$1"
8+
9+
curl \
10+
--fail \
11+
--location \
12+
--no-progress-meter \
13+
--remote-name \
14+
"https://downloads.sourceforge.net/project/sshpass/sshpass/${VERSION}/sshpass-${VERSION}.tar.gz"
15+
tar xvf "sshpass-${VERSION}.tar.gz"
16+
cd "sshpass-${VERSION}"
17+
./configure
18+
sudo make install

.ci/localhost_ansible_tests.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717

1818
with ci_lib.Fold('job_setup'):
1919
os.chmod(ci_lib.TESTS_SSH_PRIVATE_KEY_FILE, int('0600', 8))
20-
# NOTE: sshpass v1.06 causes errors so pegging to 1.05 -> "msg": "Error when changing password","out": "passwd: DS error: eDSAuthFailed\n",
21-
# there's a checksum error with "brew install http://git.io/sshpass.rb" though, so installing manually
22-
if not ci_lib.exists_in_path('sshpass'):
23-
subprocess.check_call(
24-
"curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz && \
25-
tar xvf sshpass-1.05.tar.gz && \
26-
cd sshpass-1.05 && \
27-
./configure && \
28-
sudo make install",
29-
shell=True,
30-
)
3120

3221

3322
with ci_lib.Fold('machine_prep'):

.github/workflows/tests.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,16 @@ jobs:
177177
- name: Ans_313_11
178178
python_version: '3.13'
179179
tox_env: py313-mode_ansible-ansible11
180+
- name: Ans_313_12
181+
python_version: '3.13'
182+
tox_env: py313-mode_ansible-ansible12
180183

181184
- name: Van_313_11
182185
python_version: '3.13'
183186
tox_env: py313-mode_ansible-ansible11-strategy_linear
187+
- name: Van_313_12
188+
python_version: '3.13'
189+
tox_env: py313-mode_ansible-ansible12-strategy_linear
184190

185191
- name: Mito_313
186192
python_version: '3.13'
@@ -268,11 +274,19 @@ jobs:
268274
tox_env: py313-mode_mitogen
269275

270276
- name: Loc_313_11
277+
sshpass_version: "1.10"
271278
tox_env: py313-mode_localhost-ansible11
272279

273280
- name: Van_313_11
281+
sshpass_version: "1.10"
274282
tox_env: py313-mode_localhost-ansible11-strategy_linear
275283

284+
- name: Loc_313_12
285+
tox_env: py313-mode_localhost-ansible12
286+
287+
- name: Van_313_12
288+
tox_env: py313-mode_localhost-ansible12-strategy_linear
289+
276290
steps:
277291
- uses: actions/checkout@v4
278292
- uses: actions/setup-python@v5
@@ -305,6 +319,8 @@ jobs:
305319
# GitHub macOS 12 images: python2.7 is installed, but not on $PATH
306320
echo "/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7: sys.executable: $(/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -c 'import sys; print(sys.executable)')"
307321
fi
322+
- run: .ci/install_sshpass ${{ matrix.sshpass_version }}
323+
if: ${{ matrix.sshpass_version }}
308324
- name: Install tooling
309325
run: |
310326
set -o errexit -o nounset -o pipefail

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.ansible/
12
.coverage
23
.tox
34
.venv

ansible_mitogen/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _connect_ssh(spec):
147147
'ssh_path': spec.ssh_executable(),
148148
'connect_timeout': spec.timeout(),
149149
'ssh_args': spec.ssh_args(),
150-
'ssh_debug_level': spec.mitogen_ssh_debug_level(),
150+
'ssh_debug_level': spec.verbosity(),
151151
'remote_name': get_remote_name(spec),
152152
'keepalive_count': (
153153
spec.mitogen_ssh_keepalive_count() or 10
@@ -767,7 +767,7 @@ def _stack_from_spec(self, spec, stack=(), seen_names=()):
767767
C.BECOME_ALLOW_SAME_USER):
768768
stack += (CONNECTION_METHOD[spec.become_method()](spec),)
769769

770-
return stack
770+
return ansible_mitogen.utils.unsafe.cast(stack)
771771

772772
def _build_stack(self):
773773
"""

ansible_mitogen/loaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050

5151
ANSIBLE_VERSION_MIN = (2, 10)
52-
ANSIBLE_VERSION_MAX = (2, 18)
52+
ANSIBLE_VERSION_MAX = (2, 19)
5353

5454
NEW_VERSION_MSG = (
5555
"Your Ansible version (%s) is too recent. The most recent version\n"

ansible_mitogen/mixins.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from __future__ import absolute_import, division, print_function
3030
__metaclass__ = type
3131

32+
import json
3233
import logging
3334
import os
3435
import pwd
@@ -42,7 +43,6 @@
4243

4344
from ansible.module_utils.common.text.converters import to_bytes, to_text
4445
from ansible.module_utils.six.moves import shlex_quote
45-
from ansible.parsing.utils.jsonify import jsonify
4646

4747
import mitogen.core
4848
import mitogen.select
@@ -219,8 +219,13 @@ def _transfer_data(self, remote_path, data):
219219
Used by the base _execute_module(), and in <2.4 also by the template
220220
action module, and probably others.
221221
"""
222+
if data is None and ansible_mitogen.utils.ansible_version[:2] <= (2, 18):
223+
data = '{}'
222224
if isinstance(data, dict):
223-
data = jsonify(data)
225+
try:
226+
data = json.dumps(data, ensure_ascii=False)
227+
except UnicodeDecodeError:
228+
data = json.dumps(data)
224229
if not isinstance(data, bytes):
225230
data = to_bytes(data, errors='surrogate_or_strict')
226231

@@ -402,15 +407,17 @@ def _execute_module(self, module_name=None, module_args=None, tmp=None,
402407
if not self._mitogen_rediscovered_interpreter:
403408
result['ansible_facts'][self._discovered_interpreter_key] = self._discovered_interpreter
404409

405-
if self._discovery_warnings:
410+
discovery_warnings = getattr(self, '_discovery_warnings', [])
411+
if discovery_warnings:
406412
if result.get('warnings') is None:
407413
result['warnings'] = []
408-
result['warnings'].extend(self._discovery_warnings)
414+
result['warnings'].extend(discovery_warnings)
409415

410-
if self._discovery_deprecation_warnings:
416+
discovery_deprecation_warnings = getattr(self, '_discovery_deprecation_warnings', [])
417+
if discovery_deprecation_warnings:
411418
if result.get('deprecations') is None:
412419
result['deprecations'] = []
413-
result['deprecations'].extend(self._discovery_deprecation_warnings)
420+
result['deprecations'].extend(discovery_deprecation_warnings)
414421

415422
return ansible.utils.unsafe_proxy.wrap_var(result)
416423

@@ -429,7 +436,10 @@ def _postprocess_response(self, result):
429436
"stderr": "stderr data"
430437
}
431438
"""
432-
data = self._parse_returned_data(result)
439+
if ansible_mitogen.utils.ansible_version[:2] >= (2, 19):
440+
data = self._parse_returned_data(result, profile='legacy')
441+
else:
442+
data = self._parse_returned_data(result)
433443

434444
# Cutpasted from the base implementation.
435445
if 'stdout' in data and 'stdout_lines' not in data:

ansible_mitogen/planner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def get_kwargs(self, **kwargs):
170170
"""
171171
binding = self._inv.connection.get_binding()
172172

173+
kwargs = ansible_mitogen.utils.unsafe.cast(kwargs)
173174
new = dict((mitogen.core.UnicodeType(k), kwargs[k])
174175
for k in kwargs)
175176
new.setdefault('good_temp_dir',
@@ -204,7 +205,7 @@ def get_kwargs(self, **kwargs):
204205
module=self._inv.module_name,
205206
path=self._inv.module_path,
206207
json_args=json.dumps(self._inv.module_args),
207-
env=self._inv.env,
208+
env=ansible_mitogen.utils.unsafe.cast(self._inv.env),
208209
**kwargs
209210
)
210211

@@ -546,7 +547,7 @@ def _invoke_async_task(invocation, planner):
546547
call_recv = context.call_async(
547548
ansible_mitogen.target.run_module_async,
548549
job_id=job_id,
549-
timeout_secs=invocation.timeout_secs,
550+
timeout_secs=ansible_mitogen.utils.unsafe.cast(invocation.timeout_secs),
550551
started_sender=started_recv.to_sender(),
551552
kwargs=planner.get_kwargs(),
552553
)

ansible_mitogen/runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
from io import StringIO
7474

7575
# Prevent accidental import of an Ansible module from hanging on stdin read.
76+
# FIXME Should probably be b'{}' or None. Ansible 2.19 has bytes | None = None.
7677
import ansible.module_utils.basic
7778
ansible.module_utils.basic._ANSIBLE_ARGS = '{}'
7879

@@ -635,6 +636,7 @@ def __init__(self, args, temp_dir):
635636
sys.stderr = StringIO()
636637
encoded = json.dumps({'ANSIBLE_MODULE_ARGS': args})
637638
ansible.module_utils.basic._ANSIBLE_ARGS = utf8(encoded)
639+
ansible.module_utils.basic._ANSIBLE_PROFILE = 'legacy'
638640
sys.stdin = StringIO(mitogen.core.to_text(encoded))
639641

640642
self.original_get_path = getattr(ansible.module_utils.basic,
@@ -649,7 +651,9 @@ def revert(self):
649651
sys.stdout = self.original_stdout
650652
sys.stderr = self.original_stderr
651653
sys.stdin = self.original_stdin
654+
# FIXME Should probably be b'{}' or None. Ansible 2.19 has bytes | None = None.
652655
ansible.module_utils.basic._ANSIBLE_ARGS = '{}'
656+
ansible.module_utils.basic._ANSIBLE_PROFILE = None
653657

654658

655659
class ProgramRunner(Runner):

ansible_mitogen/services.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import ansible_mitogen.loaders
5858
import ansible_mitogen.module_finder
5959
import ansible_mitogen.target
60+
import ansible_mitogen.utils
6061
import ansible_mitogen.utils.unsafe
6162

6263

@@ -338,7 +339,12 @@ def _on_context_disconnect(self, context):
338339
'ansible_mitogen.target',
339340
'mitogen.fork',
340341
'mitogen.service',
341-
)
342+
) + ((
343+
'ansible.module_utils._internal._json._profiles._module_legacy_c2m',
344+
'ansible.module_utils._internal._json._profiles._module_legacy_m2c',
345+
'ansible.module_utils._internal._json._profiles._module_modern_c2m',
346+
'ansible.module_utils._internal._json._profiles._module_legacy_m2c',
347+
) if ansible_mitogen.utils.ansible_version[:2] >= (2, 19) else ())
342348

343349
def _send_module_forwards(self, context):
344350
if hasattr(self.router.responder, 'forward_modules'):

0 commit comments

Comments
 (0)