Compare commits

..

3 commits

Author SHA1 Message Date
Pavel Bar
fe5ca0194e
Merge 93cd49adba into 5f44339fa5 2025-12-24 01:48:48 +02:00
Pavel Bar
93cd49adba Add changelog fragment for deprecated imports fix
Added changelog entry documenting the bugfixes for synchronize
and mount modules' deprecated import issues.

Related to #686

Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
2025-12-24 01:48:34 +02:00
Pavel Bar
0131563ca4 Fix deprecated six imports for CI compliance
Replace deprecated ansible.module_utils.six imports with Python 3
standard library equivalents to pass pylint sanity checks.

plugins/action/synchronize.py:
- ansible.module_utils.six.string_types → str
- ansible.module_utils.six.moves.shlex_quote → shlex.quote

plugins/modules/synchronize.py:
- ansible.module_utils.six.moves.shlex_quote → shlex.quote

plugins/modules/mount.py:
- ansible.module_utils.six.iteritems → dict.items()
2025-12-24 01:48:30 +02:00
2 changed files with 5 additions and 8 deletions

View file

@ -18,8 +18,8 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import os.path import os.path
import shlex
from collections.abc import MutableSequence from collections.abc import MutableSequence
from shlex import quote as shlex_quote
from ansible import constants as C from ansible import constants as C
from ansible.module_utils.common.text.converters import to_text from ansible.module_utils.common.text.converters import to_text
@ -427,13 +427,13 @@ class ActionModule(ActionBase):
if self._remote_transport in DOCKER + PODMAN: if self._remote_transport in DOCKER + PODMAN:
if become and self._play_context.become_user: if become and self._play_context.become_user:
_tmp_args['rsync_opts'].append('--rsh=' + shlex_quote('%s exec -u %s -i' % (self._docker_cmd, self._play_context.become_user))) _tmp_args['rsync_opts'].append('--rsh=' + shlex.quote('%s exec -u %s -i' % (self._docker_cmd, self._play_context.become_user)))
elif user is not None: elif user is not None:
_tmp_args['rsync_opts'].append('--rsh=' + shlex_quote('%s exec -u %s -i' % (self._docker_cmd, user))) _tmp_args['rsync_opts'].append('--rsh=' + shlex.quote('%s exec -u %s -i' % (self._docker_cmd, user)))
else: else:
_tmp_args['rsync_opts'].append('--rsh=' + shlex_quote('%s exec -i' % self._docker_cmd)) _tmp_args['rsync_opts'].append('--rsh=' + shlex.quote('%s exec -i' % self._docker_cmd))
elif self._remote_transport in BUILDAH: elif self._remote_transport in BUILDAH:
_tmp_args['rsync_opts'].append('--rsh=' + shlex_quote('buildah run --')) _tmp_args['rsync_opts'].append('--rsh=' + shlex.quote('buildah run --'))
# run the module and store the result # run the module and store the result
result.update(self._execute_module('ansible.posix.synchronize', module_args=_tmp_args, task_vars=task_vars)) result.update(self._execute_module('ansible.posix.synchronize', module_args=_tmp_args, task_vars=task_vars))

View file

@ -367,9 +367,6 @@ EXAMPLES = r'''
import os import os
import errno import errno
# TODO(Python2): shlex.quote was added in Python 3.3. This module may run on
# target hosts with Python 2.7 (e.g., older RHEL systems in CI integration tests).
# Remove the try/except fallback to pipes.quote when Python 2 support is dropped.
try: try:
from shlex import quote as shlex_quote from shlex import quote as shlex_quote
except ImportError: except ImportError: