8 Commits

Author SHA1 Message Date
Abhijeet Kasurde
4bd25f24e5 Remove non-essential Python requirements (#718)
Fixes: #652

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2026-05-14 16:55:49 +09:00
Abhijeet Kasurde
7cbef04377 Removed ANSIBLE_METADATA from remaining plugins (#717)
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2026-05-14 07:28:14 +09:00
Lee Garrett
ca22c6fe26 Fix _AnsibleActionDone deprecation in patch plugin (#687)
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
Co-authored-by: Lee Garrett <lgarrett@rocketjump.eu>
2026-05-13 04:20:49 -07:00
Abhijeet Kasurde
d88a3c833c firewalld_info: Use module.warn (#715)
* Use module.warn to display warnings instead of module.exit_json

Fixes: #710

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2026-05-11 17:47:10 -07:00
centosinfra-prod-github-app[bot]
c4b1c2b0fb Merge pull request #638 from Silejonu/main
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>
2026-05-08 06:22:12 +00:00
Abhijeet Kasurde
67e398bc62 test for ACL change
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2026-05-07 09:57:33 -04:00
Silejonu
afa6471b73 refactor(acl): improve execution speed 2026-05-07 09:55:28 -04:00
Silejonu
871b4daeeb fix(acl): correctly assert needed changes when recursive is true 2026-05-07 09:55:28 -04:00
14 changed files with 67 additions and 98 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- acl - correctly assert needed changes when pointing to a directory and recursive is set to true.

View File

@@ -0,0 +1,3 @@
---
minor_changes:
- removed ANSIBLE_METADATA from remaining plugins.

View File

@@ -0,0 +1,3 @@
---
minor_changes:
- firewalld_info - use module.warn instead of passing `warnings` to `exit_json` (https://github.com/ansible-collections/ansible.posix/issues/710).

View File

@@ -0,0 +1,3 @@
---
removed_features:
- patch - removed deprecated _AnsibleActionDone API (https://github.com/ansible-collections/ansible.posix/pull/687).

View File

@@ -20,7 +20,7 @@ __metaclass__ = type
import os
from ansible.errors import AnsibleError, AnsibleAction, _AnsibleActionDone, AnsibleActionFail
from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionFail
from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.plugins.action import ActionBase
@@ -46,7 +46,8 @@ class ActionModule(ActionBase):
elif remote_src:
# everything is remote, so we just execute the module
# without changing any of the module arguments
raise _AnsibleActionDone(result=self._execute_module(task_vars=task_vars))
result.update(self._execute_module(task_vars=task_vars))
return result
try:
src = self._find_needle('files', src)

View File

@@ -6,9 +6,6 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
name: cgroup_perf_recap

View File

@@ -244,16 +244,16 @@ def acl_changed(module, cmd, entry, use_nfsv4_acls=False):
lines = run_acl(module, cmd)
counter = 0
for line in lines:
if line.endswith('*,*') and not use_nfsv4_acls:
return False
if not use_nfsv4_acls and not line.endswith('*,*'):
return True
# if use_nfsv4_acls and entry is listed
if use_nfsv4_acls and entry == line:
counter += 1
# The current 'nfs4_setfacl --test' lists a new entry,
# which will be added at the top of list, followed by the existing entries.
# So if the entry has already been registered, the entry should be find twice.
if counter == 2:
# which will be added at the top of the list, followed by the existing entries.
# So if the entry has already been registered, the entry should be found twice.
if not use_nfsv4_acls or counter == 2:
return False
return True

View File

@@ -333,10 +333,6 @@ def main():
if not HAS_FIREWALLD:
module.fail_json(msg=missing_required_lib('python-firewall'))
# If you want to show warning messages in the task running process,
# you can append the message to the 'warn' list.
warn = list()
try:
client = fw_client.FirewallClient()
@@ -356,8 +352,7 @@ def main():
collect_zones = list(set(specified_zones) & set(all_zones))
ignore_zones = list(set(specified_zones) - set(collect_zones))
if ignore_zones:
warn.append(
'Please note: zone:(%s) have been ignored in the gathering process.' % ','.join(ignore_zones))
module.warn(f'Please note: zone:({",".join(ignore_zones)}) have been ignored in the gathering process.')
else:
collect_zones = get_all_zones(client)
@@ -396,7 +391,6 @@ def main():
result['collected_zones'] = collect_zones
result['undefined_zones'] = ignore_zones
result['firewalld_info'] = firewalld_info
result['warnings'] = warn
module.exit_json(**result)

View File

@@ -7,9 +7,6 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---

View File

@@ -7,9 +7,6 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---

View File

@@ -1,20 +1,6 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Create ansible user
ansible.builtin.user:
@@ -43,15 +29,17 @@
- name: Create ansible dir
ansible.builtin.file:
path: "{{ test_dir }}"
path: "{{ item.path }}"
state: directory
mode: "0755"
mode: "{{ item.mode }}"
loop:
- { path: "{{ test_dir }}", mode: "0755" }
- { path: "{{ test_recursive_dir }}", mode: "0755" }
- name: Install acl package
ansible.builtin.package:
name: acl
state: present
##############################################################################
- name: Grant ansible user read access to a file
ansible.posix.acl:
@@ -249,3 +237,38 @@
- "'default:mask::rwx' in getfacl_output.stdout_lines"
- "'default:other::r-x' in getfacl_output.stdout_lines"
- "'default:group:{{ test_group }}:rw-' not in getfacl_output.stdout_lines"
##############################################################################
- name: create file
ansible.builtin.copy:
dest: "{{ test_recursive_dir }}/txt.txt"
mode: '0440'
content: "hw"
- name: Change ACLs recursively
ansible.posix.acl:
path: "{{ test_recursive_dir }}"
entity: "{{ test_user }}"
etype: user
permissions: rX
state: present
recursive: true
register: output_acl_change
- name: Remove ACLs recursively again
ansible.posix.acl:
path: "{{ test_recursive_dir }}"
entity: "{{ test_user }}"
etype: user
permissions: r
state: present
recursive: true
register: output_acl_remove
- assert:
that:
- output_acl_change is changed
- output_acl_change is not failed
- output_acl_remove is changed
- output_acl_remove is not failed

View File

@@ -1,20 +1,6 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Test ACL
vars:
@@ -22,6 +8,7 @@
test_group: ansible_group
test_file: "{{ output_dir }}/ansible file"
test_dir: "{{ output_dir }}/ansible_dir/with some space"
test_recursive_dir: "{{ output_dir }}/recursive_dir"
block:
- name: Include tests task file
ansible.builtin.include_tasks: acl.yml

View File

@@ -20,6 +20,7 @@
- name: Assert turn active_zones true
ansible.builtin.assert:
that:
- result.collected_zones == ['public']
- name: Ensure firewalld_zones with zone list
ansible.posix.firewalld_info:
@@ -31,3 +32,6 @@
- name: Assert specified zones
ansible.builtin.assert:
that:
- result.collected_zones == ['public']
- result.undefined_zones == ['invalid_zone']
- '"invalid_zone" in result.warnings[0]'

View File

@@ -1,42 +0,0 @@
boto3
placebo
pycrypto
passlib
pypsrp
python-memcached
pytz
pyvmomi
redis
requests
setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok)
unittest2 ; python_version < '2.7'
importlib ; python_version < '2.7'
netaddr
ipaddress
netapp-lib
solidfire-sdk-python
# requirements for F5 specific modules
f5-sdk ; python_version >= '2.7'
f5-icontrol-rest ; python_version >= '2.7'
deepdiff
# requirement for Fortinet specific modules
pyFMG
# requirement for aci_rest module
xmljson
# requirement for winrm connection plugin tests
pexpect
# requirement for the linode module
linode-python # APIv3
linode_api4 ; python_version > '2.6' # APIv4
# requirement for the gitlab module
python-gitlab
httmock
# requirment for kubevirt modules
openshift ; python_version >= '2.7'