* synchronize: fix changed status with link_dest
With link_dest the module runs rsync with -vv, which also itemizes
unchanged files as '.f' followed by spaces. Any such line made the
module report no change, even when other files in the same run were
transferred, deleted or had their permissions updated.
Treat a line as unchanged only when it starts with a period and has no
attribute changes, which is how rsync lists files it did not touch.
Signed-off-by: Luca Marsella <marsluca7@gmail.com>
Assisted-by: Claude Opus 5.5
* synchronize: don't make link_dest test files world-readable
SonarCloud flags the new test tasks for granting access to others.
The test does not need it, so use 0750 and 0640 instead.
Signed-off-by: Luca Marsella <marsluca7@gmail.com>
* synchronize: read rsync markers only at the start of a line
The link_dest check split the whole output on the marker, so a file
name that contains the marker made a no-op sync report a change.
Signed-off-by: Luca Marsella <marsluca7@gmail.com>
---------
Signed-off-by: Luca Marsella <marsluca7@gmail.com>
python-firewall wraps a missing D-Bus socket in FirewallError, which the module did not catch, so Ansible reported a module crash instead of a normal failure.
Fixes#678
Assisted-by: Grok 4.7
Signed-off-by: Nikhil Jain <nikhjain@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* synchronize: use ansible_host from play vars when absent from hostvars
The synchronize action plugin built the rsync/ssh destination
exclusively from task_vars['hostvars'][inventory_hostname]. When
ansible_host was set via play-level vars: rather than inventory/
group_vars/host_vars, it was absent from that snapshot and the plugin
silently fell back to bare inventory_hostname, producing 'Host not
found' errors when ansible_host differed from the inventory name.
Fixes#469
* Create a new state, with an example and integration test
* Now that I have my PR, add in my changelog
* Fix linter issues
* Another attempt at getting the sanity tests to pass
* Fix FreeBSD integration test
* Try to get sonarcloud code analysis happy
* Change state option name
Use display.columns and get_text_width() for TASKS RECAP headers,
timestamps, and timing rows so output matches display.banner() width.
Add truncate_task_names (default false, version_added 2.3.0) with
display-width-aware truncation and padding for multibyte task names.
Add unit tests for ASCII and CJK recap rows, including the reproducer
from #773.
- Bump test container version to 8.0.0 for Ansible Core 2.18+
- Keep using 7.0.0 for Ansible Core 2.16 and 2.17. Both versions don't support Python3.13.
Signed-off-by: Hideki Saito <saito@fgrep.org>
Added lastest branches and updated information
Normalized test versions to cover all supported ones
Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
acl: correctly assert needed changes when recursive is true
SUMMARY
Right now, when setting recursive ACLs on a directory, all files in the directory are tested to check if a change is needed. If a single file has expected ACLs already set, then the test returns False and no changes are applied.
Fixes#592
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
acl
ADDITIONAL INFORMATION
I'm very much a beginner in Python, so any criticism is welcome.
Reviewed-by: Hideki Saito <saito@fgrep.org>
Fix all deprecated module_utils imports before ansible-core 2.24 removal
SUMMARY
Fixes all deprecated ansible.module_utils imports across the entire collection that will be removed in ansible-core 2.24.
This PR comprehensively addresses deprecation warnings reported in #686 by updating import statements in 20 files to use the new recommended import paths, and removes 8 unused test utility files that contained deprecated imports.
Deprecated imports replaced:
Deprecated import
Replacement
ansible.module_utils._text
ansible.module_utils.common.text.converters
ansible.module_utils.common._collections_compat
collections.abc
ansible.module_utils.six.moves.shlex_quote
shlex.quote
ansible.module_utils.six.moves.reduce
functools.reduce
ansible.module_utils.six.moves.urllib.parse.urlparse
urllib.parse.urlparse
ansible.module_utils.six.string_types
basestring/str (Python 2/3 compatible)
ansible.module_utils.six.text_type
str
ansible.module_utils.six.PY3
Removed (simplified Python 2/3 conditionals)
ansible.module_utils.six.with_metaclass
Native metaclass= syntax
ansible.module_utils.six.iteritems
dict.items()
Files fixed (20 files, 1 commit per file for easier review):
plugins/action/patch.py
plugins/action/synchronize.py
plugins/callback/cgroup_perf_recap.py
plugins/callback/json.py
plugins/callback/jsonl.py
plugins/callback/profile_roles.py
plugins/callback/profile_tasks.py
plugins/modules/acl.py
plugins/modules/authorized_key.py
plugins/modules/firewalld_info.py
plugins/modules/mount.py
plugins/modules/patch.py
plugins/modules/rhel_rpm_ostree.py
plugins/modules/rpm_ostree_upgrade.py
plugins/modules/seboolean.py
plugins/modules/synchronize.py
plugins/modules/sysctl.py
plugins/shell/csh.py
plugins/shell/fish.py
tests/unit/modules/system/test_mount.py
Files deleted (8 unused test utility files):
These files are dead code - none of them are imported or used anywhere in the test suite or the collection. Removing them also addresses Python 2.7 compatibility concerns raised in code review, as several contained deprecated imports that would be incorrect to fix for Python 2.
tests/unit/compat/builtins.py
tests/unit/mock/loader.py
tests/unit/mock/path.py
tests/unit/mock/procenv.py
tests/unit/mock/vault_helper.py
tests/unit/mock/yaml_helper.py
tests/unit/modules/conftest.py
tests/unit/modules/utils.py
Completeness verified with:
git grep -n -P '_compat|utils._text|utils.six' -- '*.py' | grep -v yml
This command returns no results, confirming all deprecated imports have been replaced.
Notes on Python 2.7 compatibility:
For modules that may run on Python 2.7 managed hosts (e.g., authorized_key.py, synchronize.py, sysctl.py), Python 2/3 compatible fallbacks were used instead of direct Python 3 replacements:
authorized_key.py: try/except ImportError for urllib.parse.urlparse (falls back to urlparse on Python 2)
synchronize.py: try/except ImportError for shlex.quote (falls back to pipes.quote on Python 2)
sysctl.py: uses sys.version_info to set string_types to str on Python 3 (basestring on Python 2)
Also removes corresponding pylint:ansible-bad-import-from entries from tests/sanity/ignore-2.21.txt and tests/sanity/ignore-2.22.txt where applicable.
Fixes#686
ISSUE TYPE
Bugfix Pull Request
ADDITIONAL INFORMATION
Approach:
Each file is fixed in a separate commit for easier code review. The changelog fragment is added in a final commit. Corresponding pylint:ansible-bad-import-from ignore entries in tests/sanity/ignore-2.21.txt and tests/sanity/ignore-2.22.txt are removed in the same commit as the file fix (or the file removal commit).
CI results:
All 59 checks passing (Azure Pipelines sanity, units, lint, Docker, Remote across ansible-core 2.17 through devel, and Zuul ansible/check).
Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Pavel Bar
Reviewed-by: Abhijeet Kasurde
These files are dead code - none of them are imported or used anywhere
in the test suite or the collection:
- tests/unit/compat/builtins.py
- tests/unit/mock/loader.py
- tests/unit/mock/path.py
- tests/unit/mock/procenv.py
- tests/unit/mock/vault_helper.py
- tests/unit/mock/yaml_helper.py
- tests/unit/modules/conftest.py
- tests/unit/modules/utils.py
Removing these files also addresses Python 2.7 compatibility concerns
raised in code review, as several contained deprecated imports that
would be incorrect to fix for Python 2.
Also removes corresponding pylint:ansible-bad-import-from entries from
tests/sanity/ignore-2.21.txt.
Related to #686
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>