Compare commits

..

2 commits

Author SHA1 Message Date
Pavel Bar
64a81b4064 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 15:45:30 +02:00
Pavel Bar
87307a91a2 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 15:45:24 +02:00
2 changed files with 8 additions and 5 deletions

View file

@ -18,8 +18,8 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os.path
import shlex
from collections.abc import MutableSequence
from shlex import quote as shlex_quote
from ansible import constants as C
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 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:
_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:
_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:
_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
result.update(self._execute_module('ansible.posix.synchronize', module_args=_tmp_args, task_vars=task_vars))

View file

@ -367,6 +367,9 @@ EXAMPLES = r'''
import os
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:
from shlex import quote as shlex_quote
except ImportError: