Compare commits

..

5 commits

Author SHA1 Message Date
Pavel Bar
965e808389
Merge 4a7182b194 into 5f44339fa5 2025-12-23 22:54:28 +02:00
Pavel Bar
4a7182b194 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-23 22:54:19 +02:00
Pavel Bar
b769fa0da2 Fix additional six deprecations for CI compliance
Replace deprecated ansible.module_utils.six imports with Python 3
standard library equivalents to pass pylint sanity checks.

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

mount.py:
- ansible.module_utils.six.iteritems → dict.items()

Related to #686

Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
2025-12-23 18:03:10 +02:00
Pavel Bar
f21a136a7a Fix deprecated module_utils imports in mount
These deprecated imports will be removed in ansible-core 2.24.
Updated to use the new recommended import paths.

- ansible.module_utils._text → ansible.module_utils.common.text.converters

Related to #686

Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
2025-12-23 18:02:39 +02:00
Pavel Bar
e9e6310bc1 Fix deprecated module_utils imports in synchronize
These deprecated imports will be removed in ansible-core 2.24.
Updated to use the new recommended import paths.

- ansible.module_utils._text → ansible.module_utils.common.text.converters
- ansible.module_utils.common._collections_compat → collections.abc

Fixes #686

Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
2025-12-23 18:02:35 +02:00
4 changed files with 12 additions and 16 deletions

View file

@ -1,8 +1,6 @@
---
minor_changes:
- plugins/action/synchronize.py - fix deprecated ``ansible.module_utils._text`` and ``ansible.module_utils.common._collections_compat`` imports (https://github.com/ansible-collections/ansible.posix/issues/686).
- plugins/action/synchronize.py - fix deprecated ``ansible.module_utils.six`` imports for CI compliance.
- plugins/modules/synchronize.py - fix deprecated ``ansible.module_utils._text`` import (https://github.com/ansible-collections/ansible.posix/issues/686).
- plugins/modules/synchronize.py - fix deprecated ``ansible.module_utils.six`` imports for CI compliance.
bugfixes:
- synchronize - fix deprecated ``ansible.module_utils._text`` and ``ansible.module_utils.common._collections_compat`` imports (https://github.com/ansible-collections/ansible.posix/issues/686).
- synchronize - fix deprecated ``ansible.module_utils.six`` imports for CI compliance.
- mount - fix deprecated ``ansible.module_utils._text`` import (https://github.com/ansible-collections/ansible.posix/issues/686).
- mount - fix deprecated ``ansible.module_utils.six`` imports for CI compliance.

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,13 +367,9 @@ EXAMPLES = r'''
import os
import errno
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_bytes, to_native
from ansible.module_utils._text import to_bytes, to_native
from ansible.module_utils.six.moves import shlex_quote
client_addr = None

View file

@ -1,5 +1,7 @@
tests/utils/shippable/timing.py shebang
plugins/action/synchronize.py pylint:ansible-bad-import-from
plugins/callback/cgroup_perf_recap.py pylint:ansible-bad-import-from
plugins/modules/mount.py pylint:ansible-bad-import-from
plugins/modules/sysctl.py pylint:ansible-bad-import-from
plugins/shell/csh.py pylint:ansible-bad-import-from
plugins/shell/fish.py pylint:ansible-bad-import-from