65 Commits

Author SHA1 Message Date
mubashirusman
cd6d33b1c0 Merge branch 'ansible-collections:main' into main 2025-09-08 10:13:34 +02:00
softwarefactory-project-zuul[bot]
6da1331018 Merge pull request #670 from felixfontein/deprecations
Use module.warn() instead of returning warnings

SUMMARY
Returning warnings as warnings has been deprecated.
Ref: #635.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
firewalld_info
mount

Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-08-16 01:03:30 +00:00
mubashir.Ijaz
2d2df3989e assertion checks 2025-08-11 17:19:39 +02:00
mubashir.Ijaz
df8413f3a0 fix try with invalid name 2025-08-08 17:43:48 +02:00
mubashir.Ijaz
f434c19e1e test assertion syntax 2025-08-08 17:32:06 +02:00
mubashir.Ijaz
481de3d2dc Validate results for --system option 2025-08-08 17:11:15 +02:00
mubashir.Ijaz
ae90bac688 Try sysctl with an invalid name 2025-08-08 16:48:00 +02:00
mubashir.Ijaz
80290d8e06 reload: false in docker tests 2025-08-08 16:32:43 +02:00
mubashir.Ijaz
560afe8217 handle ignoreerrors consistently 2025-08-08 16:13:08 +02:00
mubashir.Ijaz
571e80cdba ansible lint 2025-08-08 16:02:15 +02:00
mubashir.Ijaz
9ce933f7d0 remove trailing whitespaces 2025-08-08 15:45:45 +02:00
mubashir.Ijaz
7f8505d693 system_wide fix 2025-08-07 23:31:05 +02:00
mubashir.Ijaz
2f5210f362 Add integration system_wide tests 2025-08-07 17:47:24 +02:00
mubashirusman
a91bbf6c04 Merge branch 'ansible-collections:main' into main 2025-08-07 17:25:01 +02:00
Felix Fontein
ab8dfefd90 Use module.warn() instead of returning warnings. 2025-08-06 06:49:32 +02:00
softwarefactory-project-zuul[bot]
b96fad5e5b Merge pull request #673 from saito-hideki/pr/ci_update_20250805
[AZP] Update CI matrix

SUMMARY
Update AZP CI matrix:

Addresses #672
Bump test container version 7.0.0
Removes Ansible Core 2.15 tests. Python 3.11 is no longer supported in Container 7.0.0.

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-08-05 23:44:46 +00:00
saito-hideki
2d350e6073 AZP update CI matrix
* Addresses #672
* Bump test container version 7.0.0
* Removes Ansible Core 2.15 tests. Python 3.11 is no longer supported in Container 7.0.0.

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-08-05 14:30:30 +09:00
softwarefactory-project-zuul[bot]
ea6ef5c775 Merge pull request #665 from saito-hideki/pr/readme_20250728
Update README for release of Ansible Core 2.19

SUMMARY
README updated with the release of Ansible Core 2.19

https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_19.html

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-07-28 08:38:22 +00:00
saito-hideki
9007e20b2f README updated with the release of Ansible Core 2.19
* https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_19.html

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-28 17:12:02 +09:00
softwarefactory-project-zuul[bot]
508e3d920f Merge pull request #666 from saito-hideki/pr/azp_update_matrix_20250728
[AZP][CI] Update AZP matrix to follow ansible-test changes

SUMMARY
Update AZP matrix to follow ansible-test changes

ansible/ansible/pull/85558
ansible/ansible/pull/85561
ansible/ansible/pull/85562

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-28 06:32:06 +00:00
saito-hideki
18e023dd77 Update AZP matrix to follow ansible-test changes
* https://github.com/ansible/ansible/pull/85558
* https://github.com/ansible/ansible/pull/85561
* https://github.com/ansible/ansible/pull/85562

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-28 14:59:14 +09:00
softwarefactory-project-zuul[bot]
d3204df536 Merge pull request #660 from saito-hideki/pr_azp_syntax
[AZP] Fixed syntax error in AZP settings

SUMMARY
Fixed syntax error in AZP settings
ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-17 03:39:40 +00:00
Hideki SAITO
162e72182f Fixed syntax error in azurepileline settings
Signed-off-by: Hideki SAITO <hsaito@macallan.home.fgrep.org>
2025-07-17 12:16:09 +09:00
softwarefactory-project-zuul[bot]
1c1dd005c8 Merge pull request #654 from saito-hideki/pr/bump_core_version_220
[CI] bump ansible-core version to 2.20 for devel branch

SUMMARY
Bump ansible-core version to 2.20 for devel branch.

Bump devel test to ansible-core 2.19
Add ansible-core 2.18 to the stable list

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-10 01:00:47 +00:00
saito-hideki
40c27e2bee CI - bump ansible-core version
* bump devel to ansible-core 2.20
* add ansible-core 2.19 to stable list

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-10 09:35:28 +09:00
softwarefactory-project-zuul[bot]
c273ac2a01 Merge pull request #650 from felixfontein/callback
profile_* callbacks: avoid deprecated/deleted functions

SUMMARY
The profile_roles and profile_tasks callbacks define methods playbook_on_setup and playbook_on_stats which have been deleted/deprecated:

playbook_on_stats has been deprecated, v2_playbook_on_stats should be used instead (that one has already been there for many years: ansible/ansible@ba0e532 was added in 2015).
playbook_on_setup has been deleted (ansible/ansible@eec57ec), and its v2 variant was already deleted in 2017: ansible/ansible@59d5481

Ref: #635
ISSUE TYPE

Bugfix Pull Request
Feature Pull Request

COMPONENT NAME
profile_roles
profile_tasks

Reviewed-by: Abhijeet Kasurde
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-07-08 05:47:53 +00:00
Felix Fontein
f978998521 Add changelog fragment. 2025-06-28 16:34:47 +02:00
Felix Fontein
c319c856ed Avoid deprecated/deleted callback functions. 2025-06-28 16:29:29 +02:00
softwarefactory-project-zuul[bot]
cdb442ea48 Merge pull request #646 from saito-hideki/issue/642
[AZP] Add RHEL10 environment to CI matrix

SUMMARY
Add RHEL10 environment to CI matrix

Fixes #642

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-06-09 10:07:53 +00:00
saito-hideki
f977bffff2 [AZP] Add RHEL10 environment to CI matrix
* Fixes #642

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-06-09 18:43:43 +09:00
softwarefactory-project-zuul[bot]
dabaca4b70 Merge pull request #640 from Klaas-/Klaas-fixCI
Remove EOL FreeBSD 13.2 from CI

SUMMARY

CI seems to be failing for a month, reason is that freebsd 13.2 is no longer valid.
See ansible-collections/community.general#8607

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
CI

Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-05-20 00:22:19 +00:00
Klaas Demter
26b9b1438d Remove EOL FreeBSD 13.2 from CI 2025-05-19 18:10:38 +02:00
softwarefactory-project-zuul[bot]
1994b2cf1c Merge pull request #626 from pablomh/datetime_format
plugins/callback/profile_tasks.py: Add option to provide a different date/time format

SUMMARY
The new datetime_format key will offer the possibility of providing a different date/time format than the default one ('%A %d %B %Y  %H:%M:%S %z').

The iso8601 value can be used as an '%Y-%m-%dT%H:%M:%S.%f' alias (format of the ISO 8601 date/time standard).

The code has changed from using the time API to the datetime one in order to support sub-second precision (needed by the ISO 8601 format, for example).
Fixes: #279
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/callback/profile_tasks.py
ADDITIONAL INFORMATION

Output with no key which keeps current behavior:

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
Thursday 10 April 2025  00:52:11 +0200 (0:00:17.416)       0:00:17.453 ******** 
changed: [localhost]


Output with datetime_format = 'iso8601':

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
2025-04-10T00:55:19.967718 (0:00:15.664)       0:00:15.691 ******************** 
changed: [localhost]


Output with datetime_format = '%Y-%m-%dT%H:%M:%S.%f%z' (ISO 8601 with UTC offset information):

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
2025-04-10T00:57:49.290347+0200 (0:00:16.265)       0:00:16.293 *************** 
changed: [localhost]

Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-04-25 06:44:25 +00:00
Pablo Méndez Hernández
2f224e6a6a Add option to provide a different date/time format
The new `datetime_format` key will offer the possibility of
providing a different date/time format than the default one
(`'%A %d %B %Y  %H:%M:%S %z'`).

- The `iso8601` value can be used as an `'%Y-%m-%dT%H:%M:%S.%f'`
  alias (format of the ISO 8601 date/time standard).

The code has changed from using the `time` API to the `datetime`
one in order to support sub-second precision (needed by the ISO
8601 format, for example).

Signed-off-by: Pablo Mendez Hernandez <pablomh@redhat.com>
2025-04-17 15:57:00 +02:00
softwarefactory-project-zuul[bot]
96ec2097cc Merge pull request #631 from saito-hideki/issue/630
Fixes issue related to latest ansible-core devel branch

SUMMARY
Fixes a bug related to updating the ansible-core devel branch.

Fixes incorrect load path for json module in cgroup_perf_recap
Remove unnecessary condition from seboolean integration tests
Optimize conditions for selinux integration tests
Fixes #630

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.cgroup_perf_recap

ADDITIONAL INFORMATION
N/A
2025-04-17 00:34:06 +00:00
Hideki Saito
7b9b1f4957 Fixes issue related to updating the ansible-core devel branch
* Fixes incorrect load path for json module in cgroup_perf_recap
* Remove unnecessary condition from seboolean integration tests
* Optimize conditions for selinux integration tests
* Fixes #630

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-04-17 00:11:31 +00:00
softwarefactory-project-zuul[bot]
f0b5f039d3 Merge pull request #613 from simonLeary42/rewrite-mount-tests
improve mount integration tests

SUMMARY

added check mode tests (assert no changes made)
added comments to make file less scary

ISSUE TYPE
tests
COMPONENT NAME
mount
ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-04-10 03:58:40 +00:00
softwarefactory-project-zuul[bot]
5ceb40b600 Merge pull request #618 from saito-hideki/issie/612
[AZP] Remove ubuntu20.04 from CI tests

SUMMARY
Remove ubuntu20.04 from CI tests

Fixes #612

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-03-28 01:32:12 +00:00
Hideki Saito
2cec8cbed5 [CI] Remove ubuntu20.04 from CI tests
* Fixes #612

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-03-28 10:04:16 +09:00
Pavel Knoblokh
1b8aeb03cb sysctl: Add custom sysctl file example (#606) 2025-03-26 19:21:08 -07:00
Abhijeet Kasurde
eead50b287 Apply suggestions from code review 2025-03-26 12:36:08 -07:00
Simon Leary
4ff0e3aa13 remove assertion of changed 2025-03-26 15:20:42 -04:00
Simon Leary
979f00ce75 fix lint errors 2025-03-26 15:18:35 -04:00
softwarefactory-project-zuul[bot]
ed3d322fd5 Merge pull request #617 from Akasurde/ci_fix
[CI] update test containers

SUMMARY
Signed-off-by: Abhijeet Kasurde Akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Matt Clay
2025-03-26 19:00:30 +00:00
Abhijeet Kasurde
d9f54eb9d4 [CI] update test containers
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2025-03-26 09:02:59 -07:00
Simon Leary
7d8da00f79 add (check mode) to task name 2025-03-06 10:46:57 -05:00
Simon Leary
f087d58cbe fix bugs 2025-03-05 00:39:46 +00:00
Simon Leary
eb740e97d4 add check mode tests, add comments 2025-03-05 00:33:11 +00:00
softwarefactory-project-zuul[bot]
44a2151dbf Merge pull request #604 from saito-hideki/pr/bump_up_version_3.0.0
Bump version to 3.0.0 for the next release

SUMMARY
Bump version to 3.0.0 for the next release on main branch:

Fixes #603

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION

None
2024-12-10 08:59:03 +00:00
Hideki Saito
83288b9020 Bump version to 3.0.0 for the next release
* Fixes #603

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-12-10 17:30:22 +09:00
softwarefactory-project-zuul[bot]
4c6898ee6e Merge pull request #600 from saito-hideki/release_2.0.0
Release 2.0.0 commit

SUMMARY
Release 2.0.0 commit

Release Plan #149

ISSUE TYPE
Feature Pull Request
COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
This will be merged on 5 December if there are no problems

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-12-05 00:48:30 +00:00
Hideki Saito
f5eae12146 Release 2.0.0 commit
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-12-04 09:46:44 +09:00
softwarefactory-project-zuul[bot]
f632fad9d4 Merge pull request #598 from saito-hideki/issue/586
[Breaking Change] [firewalld] Change type of icmp_block_inversion option from str to bool

SUMMARY
Changed the type of icmp_block_inversion option from str to bool

Fixes #586

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.firewalld

ADDITIONAL INFORMATION
Related  #582 and #584

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-12-02 23:50:26 +00:00
softwarefactory-project-zuul[bot]
74edb72249 Merge pull request #597 from vbotka/mount-fix-comment
Remove comment from fstab entry on updating.

SUMMARY
Fix #595.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ansible.posix.mount
ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Vladimir Botka <vbotka@gmail.com>
2024-11-29 02:59:28 +00:00
Vladimir Botka
91129ed381 Fix changelog fragment module name. 2024-11-29 03:34:14 +01:00
Vladimir Botka
7b8d627552 Changelog fragment added. 2024-11-28 08:17:41 +01:00
Hideki Saito
6175a5028b Change type of icmp_block_inversion option from str to bool
* Fixes #586

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-28 14:19:20 +09:00
Vladimir Botka
8e34860d6c Fix #595. Remove comment from fstab entry on updating. 2024-11-21 20:54:27 +01:00
MubashirUsman
6280bb8ec8 Add integration test for --system option 2024-11-03 23:21:39 +01:00
mubashirusman
3b79155e68 Merge branch 'ansible-collections:main' into main 2024-11-03 23:07:55 +01:00
mubashirusman
05724a097b Merge branch 'ansible-collections:main' into main 2024-10-15 22:26:52 +02:00
MubashirUsman
7e1b76c46e write sysctl reverted 2024-05-19 17:47:12 +02:00
MubashirUsman
505a4aaa09 system_wide in defining module 2024-05-19 17:29:02 +02:00
MubashirUsman
d70d2aaaa7 read sysctl_dir files 2024-05-19 16:29:36 +02:00
MubashirUsman
806ff5c1a3 added sysctl_dirs variable and system_wide var 2024-05-19 13:54:43 +02:00
26 changed files with 540 additions and 150 deletions

View File

@@ -3,8 +3,23 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2024, Ansible Project
# Use a more permissive profile due to documentation parsing issues
profile: min
skip_list:
- meta-runtime[unsupported-version] # Tis rule doesn't make any sense
- meta-runtime[unsupported-version] # This rule doesn't make any sense
- fqcn[deep] # This rule produces false positives for files in tests/unit/plugins/action/fixtures/
- no-relative-paths # Temporary skip due to documentation parsing issue
- parser-error # Skip documentation parsing errors
- syntax-check # Skip syntax check issues in documentation
- load-failure # Skip module loading failures during documentation parsing
- args # Skip argument validation errors in documentation
exclude_paths:
- changelogs/
# Enable specific rules we want to keep
enable_list:
- yaml
- name
- var-naming

View File

@@ -37,7 +37,7 @@ variables:
resources:
containers:
- container: default
image: quay.io/ansible/azure-pipelines-test-container:6.0.0
image: quay.io/ansible/azure-pipelines-test-container:7.0.0
pool: Standard
@@ -64,7 +64,7 @@ stages:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.19/{0OI}
testFormat: 2.19/{0}
targets:
- name: Sanity
test: sanity
@@ -92,7 +92,6 @@ stages:
dependsOn: []
jobs:
- template: templates/matrix.yml
I
parameters:
nameFormat: "{0}"
testFormat: 2.17/{0}
@@ -116,19 +115,6 @@ stages:
test: sanity
- name: Units
test: units
- stage: Sanity_2_15
displayName: Ansible 2.15 sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.15/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
## Docker
- stage: Docker_devel
displayName: Docker devel
@@ -138,8 +124,8 @@ stages:
parameters:
testFormat: devel/linux/{0}/1
targets:
- name: Fedora 41
test: fedora41
- name: Fedora 42
test: fedora42
- name: Ubuntu 22.04
test: ubuntu2204
- name: Ubuntu 24.04
@@ -150,7 +136,7 @@ stages:
jobs:
- template: templates/matrix.yml
parameters:
testFormat: devel/linux/{0}/1
testFormat: 2.19/linux/{0}/1
targets:
- name: Fedora 41
test: fedora41
@@ -199,23 +185,6 @@ stages:
- name: Ubuntu 22.04
test: ubuntu2204
- stage: Docker_2_15
displayName: Docker 2.15
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.15/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- name: Fedora 37
test: fedora37
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 22.04
test: ubuntu2204
## Remote
- stage: Remote_devel
displayName: Remote devel
@@ -227,10 +196,10 @@ stages:
targets:
- name: RHEL 10.0
test: rhel/10.0
- name: RHEL 9.5
test: rhel/9.5
- name: FreeBSD 14.2
test: freebsd/14.2
- name: RHEL 9.6
test: rhel/9.6
- name: FreeBSD 14.3
test: freebsd/14.3
- name: FreeBSD 13.5
test: freebsd/13.5
- stage: Remote_2_19
@@ -239,7 +208,7 @@ stages:
jobs:
- template: templates/matrix.yml
parameters:
testFormat: devel/{0}/1
testFormat: 2.19/{0}/1
targets:
- name: RHEL 10.0
test: rhel/10.0
@@ -259,8 +228,8 @@ stages:
targets:
- name: RHEL 9.4
test: rhel/9.4
- name: FreeBSD 13.3
test: freebsd/13.3
- name: FreeBSD 13.5
test: freebsd/13.5
- stage: Remote_2_17
displayName: Remote 2.17
dependsOn: []
@@ -271,8 +240,8 @@ stages:
targets:
- name: RHEL 9.3
test: rhel/9.3
- name: FreeBSD 13.3
test: freebsd/13.3
- name: FreeBSD 13.5
test: freebsd/13.5
- stage: Remote_2_16
displayName: Remote 2.16
dependsOn: []
@@ -286,29 +255,11 @@ stages:
- name: RHEL 9.2
test: rhel/9.2
- stage: Remote_2_15
displayName: Remote 2.15
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.15/{0}/1
targets:
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.7
test: rhel/8.7
- name: RHEL 9.1
test: rhel/9.1
## Finally
- stage: Summary
condition: succeededOrFailed()
dependsOn:
- Sanity_2_15
- Remote_2_15
- Docker_2_15
- Sanity_2_16
- Remote_2_16
- Docker_2_16

View File

@@ -4,27 +4,6 @@ ansible.posix Release Notes
.. contents:: Topics
v2.1.0
======
Release Summary
---------------
This is the minor release of the ``ansible.posix`` collection.
This changelog contains all changes to the modules and plugins
in the stable-2 branch that have been added after the release of
``ansible.posix`` 2.0.0
Minor Changes
-------------
- profile_tasks and profile_roles callback plugins - avoid deleted/deprecated callback functions, instead use modern interface that was introduced a longer time ago (https://github.com/ansible-collections/ansible.posix/issues/650).
Bugfixes
--------
- ansible.posix.cgroup_perf_recap - fixes json module load path (https://github.com/ansible-collections/ansible.posix/issues/630).
v2.0.0
======

View File

@@ -21,7 +21,7 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de
* Python:
* The Python interpreter version must meet Ansible Core's requirements.
* Ansible Core:
- ansible-core 2.15 or later
- ansible-core 2.16 or later
## Installation
@@ -46,10 +46,10 @@ To upgrade the collection to the latest available version, run the following com
ansible-galaxy collection install ansible.posix --upgrade
```
You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version 1.0.0:
You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version 2.0.0:
```shell
ansible-galaxy collection install ansible.posix:==1.0.0
ansible-galaxy collection install ansible.posix:==2.0.0
```
See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details.
@@ -78,11 +78,10 @@ ansible-doc -t callback ansible.posix.profile_tasks
The following ansible-core versions have been tested with this collection:
- ansible-core 2.19 (devel)
- ansible-core 2.18 (stable) *
- ansible-core 2.20 (devel)
- ansible-core 2.19 (stable) *
- ansible-core 2.18 (stable)
- ansible-core 2.17 (stable)
- ansible-core 2.16 (stable)
- ansible-core 2.15 (stable)
## Contributing

View File

@@ -490,25 +490,3 @@ releases:
- 597_remove_fstab_comment_on_updating.yml
- 598_icmp_block_inversion.yml
release_date: '2024-12-04'
2.1.0:
changes:
bugfixes:
- ansible.posix.cgroup_perf_recap - fixes json module load path (https://github.com/ansible-collections/ansible.posix/issues/630).
minor_changes:
- profile_tasks and profile_roles callback plugins - avoid deleted/deprecated
callback functions, instead use modern interface that was introduced a longer
time ago (https://github.com/ansible-collections/ansible.posix/issues/650).
release_summary: 'This is the minor release of the ``ansible.posix`` collection.
This changelog contains all changes to the modules and plugins
in the stable-2 branch that have been added after the release of
``ansible.posix`` 2.0.0'
fragments:
- 2.1.0.yml
- 631_fixes_module_path.yml
- 642_ci_add_rhel10.yml
- 650-profile_tasks_roles.yml
- 654_ci_bump_core_version.yml
release_date: '2025-07-16'

View File

@@ -0,0 +1,2 @@
trivial:
- Bump version to 3.0.0 for the next release (https://github.com/ansible-collections/ansible.posix/issues/603).

View File

@@ -0,0 +1,2 @@
trivial:
- Remove ubuntu20.04 from CI tests (https://github.com/ansible-collections/ansible.posix/issues/612).

View File

@@ -0,0 +1,3 @@
---
minor_changes:
- profile_tasks - Add option to provide a different date/time format (https://github.com/ansible-collections/ansible.posix/issues/279).

View File

@@ -0,0 +1,6 @@
---
bugfixes:
- ansible.posix.cgroup_perf_recap - fixes json module load path (https://github.com/ansible-collections/ansible.posix/issues/630).
trivial:
- ansible.posix.seboolean - remove unnecessary condition from seboolean integration tests (https://github.com/ansible-collections/ansible.posix/issues/630).
- ansible.posix.selinux - optimize conditions for selinux integration tests (https://github.com/ansible-collections/ansible.posix/issues/630).

View File

@@ -0,0 +1,2 @@
trivial:
- Add Red Hat Enterprise Linux 10.0 to the CI matrix (https://github.com/ansible-collections/ansible.posix/issues/642).

View File

@@ -0,0 +1,2 @@
minor_changes:
- "profile_tasks and profile_roles callback plugins - avoid deleted/deprecated callback functions, instead use modern interface that was introduced a longer time ago (https://github.com/ansible-collections/ansible.posix/issues/650)."

View File

@@ -0,0 +1,3 @@
---
trivial:
- Bump ansible-core version to 2.20 of devel branch and add 2.19 to CI

View File

@@ -0,0 +1,2 @@
trivial:
- AZP - fixed syntax error in CI test.

View File

@@ -0,0 +1,3 @@
---
trivial:
- README - Update README to reflect Ansible Core 2.19 release.

View File

@@ -0,0 +1,3 @@
---
trivial:
- AZP - Update AZP matrix to follow ansible-test changes.

View File

@@ -0,0 +1,3 @@
bugfixes:
- "firewalld_info - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."
- "mount - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."

View File

@@ -0,0 +1,2 @@
trivial:
- Update AZP CI matrix (https://github.com/ansible-collections/ansible.posix/issues/673).

View File

@@ -1,7 +1,7 @@
---
namespace: ansible
name: posix
version: 2.1.0
version: 3.0.0
readme: README.md
authors:
- Ansible (github.com/ansible)

View File

@@ -1,2 +1,2 @@
---
requires_ansible: ">=2.15.0"
requires_ansible: ">=2.16.0"

View File

@@ -52,6 +52,17 @@ DOCUMENTATION = '''
- section: callback_profile_tasks
key: summary_only
version_added: 1.5.0
datetime_format:
description:
- Datetime format, as expected by the C(strftime) and C(strptime) methods.
An C(iso8601) alias will be translated to C('%Y-%m-%dT%H:%M:%S.%f') if that datetime standard wants to be used.
default: '%A %d %B %Y %H:%M:%S %z'
env:
- name: PROFILE_TASKS_DATETIME_FORMAT
ini:
- section: callback_profile_tasks
key: datetime_format
version_added: 3.0.0
'''
EXAMPLES = '''
@@ -72,14 +83,15 @@ sample output: >
'''
import collections
import time
from datetime import datetime
from ansible.module_utils.six.moves import reduce
from ansible.plugins.callback import CallbackBase
# define start time
t0 = tn = time.time()
dt0 = dtn = datetime.now().astimezone()
def secondsToStr(t):
@@ -104,17 +116,18 @@ def filled(msg, fchar="*"):
def timestamp(self):
if self.current is not None:
elapsed = time.time() - self.stats[self.current]['started']
elapsed = (datetime.now().astimezone() - self.stats[self.current]['started']).total_seconds()
self.stats[self.current]['elapsed'] += elapsed
def tasktime():
global tn
time_current = time.strftime('%A %d %B %Y %H:%M:%S %z')
time_elapsed = secondsToStr(time.time() - tn)
time_total_elapsed = secondsToStr(time.time() - t0)
tn = time.time()
return filled('%s (%s)%s%s' % (time_current, time_elapsed, ' ' * 7, time_total_elapsed))
def tasktime(self):
global dtn
cdtn = datetime.now().astimezone()
datetime_current = cdtn.strftime(self.datetime_format)
time_elapsed = secondsToStr((cdtn - dtn).total_seconds())
time_total_elapsed = secondsToStr((cdtn - dt0).total_seconds())
dtn = cdtn
return filled('%s (%s)%s%s' % (datetime_current, time_elapsed, ' ' * 7, time_total_elapsed))
class CallbackModule(CallbackBase):
@@ -134,6 +147,7 @@ class CallbackModule(CallbackBase):
self.sort_order = None
self.summary_only = None
self.task_output_limit = None
self.datetime_format = None
super(CallbackModule, self).__init__()
@@ -159,9 +173,14 @@ class CallbackModule(CallbackBase):
else:
self.task_output_limit = int(self.task_output_limit)
self.datetime_format = self.get_option('datetime_format')
if self.datetime_format is not None:
if self.datetime_format == 'iso8601':
self.datetime_format = '%Y-%m-%dT%H:%M:%S.%f'
def _display_tasktime(self):
if not self.summary_only:
self._display.display(tasktime())
self._display.display(tasktime(self))
def _record_task(self, task):
"""
@@ -176,10 +195,11 @@ class CallbackModule(CallbackBase):
# with the same UUID is executed when `serial` is specified in a playbook.
# elapsed: Elapsed time since the first serialized task was started
self.current = task._uuid
dtn = datetime.now().astimezone()
if self.current not in self.stats:
self.stats[self.current] = {'started': time.time(), 'elapsed': 0.0, 'name': task.get_name()}
self.stats[self.current] = {'started': dtn, 'elapsed': 0.0, 'name': task.get_name()}
else:
self.stats[self.current]['started'] = time.time()
self.stats[self.current]['started'] = dtn
if self._display.verbosity >= 2:
self.stats[self.current]['path'] = task.get_path()
@@ -193,7 +213,7 @@ class CallbackModule(CallbackBase):
# Align summary report header with other callback plugin summary
self._display.banner("TASKS RECAP")
self._display.display(tasktime())
self._display.display(tasktime(self))
self._display.display(filled("", fchar="="))
timestamp(self)

View File

@@ -319,7 +319,6 @@ def main():
active_zones=module.params['active_zones'],
collected_zones=list(),
undefined_zones=list(),
warnings=list(),
)
# Exit with failure message if requirements modules are not installed.

View File

@@ -279,7 +279,7 @@ def _set_mount_save_old(module, args):
old_lines = []
exists = False
changed = False
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args) if k != 'warnings'])
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args)])
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
if platform.system() == 'SunOS':
@@ -804,7 +804,6 @@ def main():
passno='-',
fstab=module.params['fstab'],
boot='yes' if module.params['boot'] else 'no',
warnings=[]
)
if args['fstab'] is None:
args['fstab'] = '/etc/vfstab'
@@ -816,7 +815,6 @@ def main():
passno='0',
fstab=module.params['fstab'],
boot='yes',
warnings=[]
)
if args['fstab'] is None:
args['fstab'] = '/etc/fstab'
@@ -834,8 +832,7 @@ def main():
linux_mounts = get_linux_mounts(module)
if linux_mounts is None:
args['warnings'].append('Cannot open file /proc/self/mountinfo.'
' Bind mounts might be misinterpreted.')
module.warn('Cannot open file /proc/self/mountinfo. Bind mounts might be misinterpreted.')
# Override defaults with user specified params
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
@@ -847,7 +844,7 @@ def main():
# specified in 'opts', mount module will ignore 'boot'.
opts = args['opts'].split(',')
if module.params['boot'] and 'noauto' in opts:
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
module.warn("Ignore the 'boot' due to 'opts' contains 'noauto'.")
elif not module.params['boot']:
args['boot'] = 'no'
opts.append('noauto')

View File

@@ -56,6 +56,16 @@ options:
- Verify token value with the sysctl command and set with C(-w) if necessary.
type: bool
default: false
system_wide:
description:
- If V(true), uses C(sysctl --system) behavior to reload all sysctl configuration files.
- This will reload configuration from C(/etc/sysctl.d/*.conf), C(/run/sysctl.d/*.conf),
C(/usr/local/lib/sysctl.d/*.conf), C(/usr/lib/sysctl.d/*.conf), C(/lib/sysctl.d/*.conf),
and C(/etc/sysctl.conf) in that order.
- If V(false), only reloads the specific sysctl file defined by O(sysctl_file).
- Only applies when O(reload) is V(true).
type: bool
default: false
author:
- David CHANIAL (@davixx)
'''
@@ -80,6 +90,13 @@ EXAMPLES = r'''
sysctl_file: /tmp/test_sysctl.conf
reload: false
# Enable resource limits management in FreeBSD
- ansible.posix.sysctl:
name: kern.racct.enable
value: '1'
sysctl_file: /boot/loader.conf
reload: false
# Set ip forwarding on in /proc and verify token value with the sysctl command
- ansible.posix.sysctl:
name: net.ipv4.ip_forward
@@ -93,6 +110,14 @@ EXAMPLES = r'''
sysctl_set: true
state: present
reload: true
# Set vm.swappiness and reload all system sysctl configuration files (equivalent to sysctl --system)
- ansible.posix.sysctl:
name: vm.swappiness
value: '10'
state: present
reload: true
system_wide: true
'''
# ==============================================================
@@ -101,6 +126,7 @@ import os
import platform
import re
import tempfile
import glob
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import string_types
@@ -114,17 +140,30 @@ class SysctlModule(object):
# success or failure.
LANG_ENV = {'LANG': 'C', 'LC_ALL': 'C', 'LC_MESSAGES': 'C'}
# We define a variable to keep all the directories to be read, equivalent to
# (/sbin/sysctl --system) option
SYSCTL_DIRS = [
'/etc/sysctl.d/*.conf',
'/run/sysctl.d/*.conf',
'/usr/local/lib/sysctl.d/*.conf',
'/usr/lib/sysctl.d/*.conf',
'/lib/sysctl.d/*.conf',
'/etc/sysctl.conf'
]
def __init__(self, module):
self.module = module
self.args = self.module.params
self.sysctl_cmd = self.module.get_bin_path('sysctl', required=True)
self.sysctl_file = self.args['sysctl_file']
self.system_wide = self.args['system_wide']
self.proc_value = None # current token value in proc fs
self.file_value = None # current token value in file
self.file_lines = [] # all lines in the file
self.file_values = {} # dict of token values
self.system_wide_file_value = None # current token value from system-wide files
self.changed = False # will change occur
self.set_proc = False # does sysctl need to set value
@@ -154,19 +193,36 @@ class SysctlModule(object):
if thisname not in self.file_values:
self.file_values[thisname] = None
# if system_wide is enabled, also check system-wide configuration
if self.system_wide:
system_wide_values = self.read_system_wide_sysctl_files()
# If the value exists in system-wide config, use that for comparison
if thisname in system_wide_values:
self.system_wide_file_value = system_wide_values[thisname]
else:
self.system_wide_file_value = None
else:
self.system_wide_file_value = None
# update file contents with desired token/value
self.fix_lines()
# what do we need to do now?
if self.file_values[thisname] is None and self.args['state'] == "present":
# Determine the effective current value (system-wide takes precedence if enabled)
if self.system_wide and self.system_wide_file_value is not None:
current_file_value = self.system_wide_file_value
else:
current_file_value = self.file_values[thisname]
if current_file_value is None and self.args['state'] == "present":
self.changed = True
self.write_file = True
elif self.file_values[thisname] is None and self.args['state'] == "absent":
elif current_file_value is None and self.args['state'] == "absent":
self.changed = False
elif self.file_values[thisname] and self.args['state'] == "absent":
elif current_file_value and self.args['state'] == "absent":
self.changed = True
self.write_file = True
elif self.file_values[thisname] != self.args['value']:
elif current_file_value != self.args['value']:
self.changed = True
self.write_file = True
# with reload=yes we should check if the current system values are
@@ -299,15 +355,25 @@ class SysctlModule(object):
# https://github.com/ansible/ansible/issues/58158
return
else:
# system supports reloading via the -p flag to sysctl, so we'll use that
sysctl_args = [self.sysctl_cmd, '-p', self.sysctl_file]
if self.args['ignoreerrors']:
sysctl_args.insert(1, '-e')
if self.system_wide:
for sysctl_file in self.SYSCTL_DIRS:
for conf_file in glob.glob(sysctl_file):
sysctl_args = [self.sysctl_cmd, '-p', conf_file]
if self.args['ignoreerrors']:
sysctl_args.insert(1, '-e')
rc, out, err = self.module.run_command(sysctl_args, environ_update=self.LANG_ENV)
if rc != 0 or self._stderr_failed(err):
self.module.fail_json(msg="Failed to reload sysctl: %s" % to_native(out) + to_native(err))
else:
# system supports reloading via the -p flag to sysctl, so we'll use that
sysctl_args = [self.sysctl_cmd, '-p', self.sysctl_file]
if self.args['ignoreerrors']:
sysctl_args.insert(1, '-e')
rc, out, err = self.module.run_command(sysctl_args, environ_update=self.LANG_ENV)
rc, out, err = self.module.run_command(sysctl_args, environ_update=self.LANG_ENV)
if rc != 0 or self._stderr_failed(err):
self.module.fail_json(msg="Failed to reload sysctl: %s" % to_native(out) + to_native(err))
if rc != 0 or self._stderr_failed(err):
self.module.fail_json(msg="Failed to reload sysctl: %s" % to_native(out) + to_native(err))
# ==============================================================
# SYSCTL FILE MANAGEMENT
@@ -337,6 +403,35 @@ class SysctlModule(object):
v = v.strip()
self.file_values[k] = v.strip()
# Get the token value from all system-wide sysctl files
def read_system_wide_sysctl_files(self):
"""Read all system-wide sysctl configuration files when system_wide=True"""
system_values = {}
for sysctl_pattern in self.SYSCTL_DIRS:
for conf_file in glob.glob(sysctl_pattern):
if os.path.isfile(conf_file):
try:
with open(conf_file, "r") as read_file:
lines = read_file.readlines()
for line in lines:
line = line.strip()
# don't split empty lines or comments or line without equal sign
if not line or line.startswith(("#", ";")) or "=" not in line:
continue
k, v = line.split('=', 1)
k = k.strip()
v = v.strip()
# Later files override earlier ones (mimicking sysctl --system behavior)
system_values[k] = v.strip()
except IOError:
# Skip files that can't be read
continue
return system_values
# Fix the value in the sysctl file content
def fix_lines(self):
checked = []
@@ -394,7 +489,8 @@ def main():
reload=dict(default=True, type='bool'),
sysctl_set=dict(default=False, type='bool'),
ignoreerrors=dict(default=False, type='bool'),
sysctl_file=dict(default='/etc/sysctl.conf', type='path')
sysctl_file=dict(default='/etc/sysctl.conf', type='path'),
system_wide=dict(default=False, type='bool'), # system_wide parameter
),
supports_check_mode=True,
required_if=[('state', 'present', ['value'])],

View File

@@ -1,3 +1,5 @@
needs/privileged
needs/root
destructive
shippable/posix/group1
skip/aix

View File

@@ -140,8 +140,8 @@
ansible.posix.sysctl:
name: test.invalid
value: 1
register: sysctl_test3
ignore_errors: true
register: sysctl_test3
- name: Debug sysctl_test3
ansible.builtin.debug:
@@ -229,6 +229,91 @@
ansible.builtin.assert:
that:
- sysctl_test4 is failed
##
## sysctl --system
##
- name: Set vm.swappiness to 10 with --system option
ansible.posix.sysctl:
name: vm.swappiness
value: 10
state: present
reload: false
sysctl_set: true
system_wide: true
register: sysctl_system_test1
- name: Check with sysctl command
ansible.builtin.command: sysctl vm.swappiness
changed_when: false
register: sysctl_check_system1
- name: Debug sysctl_system_test1 sysctl_check_system1
ansible.builtin.debug:
var: item
verbosity: 1
with_items:
- "{{ sysctl_system_test1 }}"
- "{{ sysctl_check_system1 }}"
- name: Validate results for --system option
ansible.builtin.assert:
that:
- sysctl_system_test1 is changed
- "'10' in sysctl_check_system1.stdout"
# Test system_wide with reload=true
- name: Set vm.dirty_ratio to 20 with system_wide and reload=true
ansible.posix.sysctl:
name: vm.dirty_ratio
value: 20
state: present
reload: true
system_wide: true
register: sysctl_system_reload_test
- name: Check vm.dirty_ratio value
ansible.builtin.command: sysctl -n vm.dirty_ratio
changed_when: false
register: sysctl_check_dirty_ratio
- name: Validate system_wide with reload
ansible.builtin.assert:
that:
- sysctl_system_reload_test is changed
- sysctl_check_dirty_ratio.stdout == "20"
# Test system_wide=false behavior (default)
- name: Create custom sysctl file for testing
ansible.builtin.copy:
content: |
# Custom sysctl test file
vm.dirty_background_ratio=5
dest: "{{ output_dir_test }}/custom_sysctl.conf"
mode: "0644"
- name: Set vm.dirty_background_ratio with system_wide=false
ansible.posix.sysctl:
name: vm.dirty_background_ratio
value: 10
state: present
reload: true
system_wide: false
sysctl_file: "{{ output_dir_test }}/custom_sysctl.conf"
register: sysctl_system_false_test
- name: Check custom sysctl file content
ansible.builtin.command: cat {{ output_dir_test }}/custom_sysctl.conf
changed_when: false
register: custom_sysctl_content
- name: Validate system_wide=false behavior
ansible.builtin.assert:
that:
- sysctl_system_false_test is changed
- "'vm.dirty_background_ratio=10' in custom_sysctl_content.stdout"
- name: Test on RHEL VMs
when:
@@ -366,3 +451,36 @@
that:
- stat_result.stat.islnk is defined and stat_result.stat.islnk
- stat_result.stat.lnk_source == '/tmp/ansible_sysctl_test.conf'
# Test sysctl: --system
- name: Set vm.swappiness to 10 with --system option
ansible.posix.sysctl:
name: vm.swappiness
value: 10
state: present
reload: false
sysctl_set: true
system_wide: true
register: sysctl_system_test1
- name: Check with sysctl command
ansible.builtin.command: sysctl vm.swappiness
changed_when: false
register: sysctl_check_system1
- name: Debug sysctl_system_test1 sysctl_check_system1
ansible.builtin.debug:
var: item
verbosity: 1
with_items:
- "{{ sysctl_system_test1 }}"
- "{{ sysctl_check_system1 }}"
- name: Validate results for --system option
ansible.builtin.assert:
that:
- sysctl_system_test1 is changed
- sysctl_check_system1.stdout_lines == ["vm.swappiness = 10"]
- name: Include system_wide specific tests
ansible.builtin.include_tasks: system_wide_tests.yml

View File

@@ -0,0 +1,203 @@
---
# Additional tests specifically for system_wide parameter functionality
- name: Test system_wide parameter basic functionality
block:
# Test system_wide with a simple sysctl parameter
- name: Set vm.swappiness with system_wide=true (first time)
ansible.posix.sysctl:
name: vm.swappiness
value: 35
state: present
reload: false
system_wide: true
register: sysctl_system_wide_first_test
- name: Debug first test result
ansible.builtin.debug:
var: sysctl_system_wide_first_test
- name: Set vm.swappiness with system_wide=true (second time - should not change)
ansible.posix.sysctl:
name: vm.swappiness
value: 35
state: present
reload: false
system_wide: true
register: sysctl_system_wide_second_test
- name: Debug second test result
ansible.builtin.debug:
var: sysctl_system_wide_second_test
- name: Validate system_wide basic functionality
ansible.builtin.assert:
that:
- sysctl_system_wide_first_test is changed
- sysctl_system_wide_second_test is not changed
# Test system_wide with reload=true
- name: Set vm.dirty_expire_centisecs with system_wide=true and reload
ansible.posix.sysctl:
name: vm.dirty_expire_centisecs
value: 3000
state: present
reload: true
system_wide: true
register: sysctl_system_wide_reload_test
- name: Check vm.dirty_expire_centisecs value
ansible.builtin.command: sysctl -n vm.dirty_expire_centisecs
changed_when: false
register: sysctl_check_dirty_expire
- name: Validate system_wide with reload=true
ansible.builtin.assert:
that:
- sysctl_system_wide_reload_test is changed
- sysctl_check_dirty_expire.stdout == "3000"
# Test system_wide=false behavior (default)
- name: Create custom sysctl file for testing system_wide=false
ansible.builtin.copy:
content: |
# Custom sysctl test file
vm.dirty_background_ratio=5
dest: "{{ output_dir_test }}/custom_sysctl.conf"
mode: "0644"
- name: Set vm.dirty_background_ratio with system_wide=false
ansible.posix.sysctl:
name: vm.dirty_background_ratio
value: 10
state: present
reload: true
system_wide: false
sysctl_file: "{{ output_dir_test }}/custom_sysctl.conf"
register: sysctl_system_false_test
- name: Check custom sysctl file content
ansible.builtin.command: cat {{ output_dir_test }}/custom_sysctl.conf
changed_when: false
register: custom_sysctl_content
- name: Validate system_wide=false behavior
ansible.builtin.assert:
that:
- sysctl_system_false_test is changed
- "'vm.dirty_background_ratio=10' in custom_sysctl_content.stdout"
# Test system_wide with check mode
- name: Test system_wide in check mode
ansible.posix.sysctl:
name: vm.swappiness
value: 25
state: present
reload: true
system_wide: true
check_mode: true
register: sysctl_system_wide_check_mode
- name: Validate check mode works with system_wide
ansible.builtin.assert:
that:
- sysctl_system_wide_check_mode is changed
# Test system_wide with missing directories (should not fail)
- name: Test system_wide with potentially missing directories
ansible.posix.sysctl:
name: vm.overcommit_memory
value: 1
state: present
reload: true
system_wide: true
ignoreerrors: true
register: sysctl_system_wide_missing_dirs
- name: Validate system_wide handles missing directories
ansible.builtin.assert:
that:
- sysctl_system_wide_missing_dirs is not failed
- name: Test system_wide with multiple configuration files (RHEL/CentOS only)
when:
- ansible_facts.os_family == 'RedHat'
- ansible_facts.virtualization_type != 'docker'
block:
# Test that system_wide processes multiple configuration files
- name: Create test sysctl.d file
ansible.builtin.copy:
content: |
# Test system-wide sysctl reload
vm.dirty_writeback_centisecs=500
dest: /etc/sysctl.d/99-ansible-test.conf
mode: "0644"
backup: true
register: test_sysctl_file
- name: Apply setting with system_wide to test multiple file processing
ansible.posix.sysctl:
name: vm.overcommit_memory
value: 1
state: present
reload: true
system_wide: true
register: sysctl_multifile_test
- name: Verify both settings are applied
ansible.builtin.shell: |
sysctl -n vm.dirty_writeback_centisecs
sysctl -n vm.overcommit_memory
changed_when: false
register: sysctl_multifile_check
- name: Validate multiple file processing
ansible.builtin.assert:
that:
- sysctl_multifile_test is changed
- "'500' in sysctl_multifile_check.stdout"
- "'1' in sysctl_multifile_check.stdout"
- name: Cleanup test sysctl.d file
ansible.builtin.file:
path: /etc/sysctl.d/99-ansible-test.conf
state: absent
- name: Test system_wide parameter combinations
block:
# Test system_wide with sysctl_set
- name: Test system_wide with sysctl_set=true
ansible.posix.sysctl:
name: vm.swappiness
value: 15
state: present
reload: true
system_wide: true
sysctl_set: true
register: sysctl_system_wide_set_test
- name: Check vm.swappiness value after system_wide + sysctl_set
ansible.builtin.command: sysctl -n vm.swappiness
changed_when: false
register: sysctl_check_swappiness_set
- name: Validate system_wide with sysctl_set
ansible.builtin.assert:
that:
- sysctl_system_wide_set_test is changed
- sysctl_check_swappiness_set.stdout == "15"
# Test system_wide with reload=false (should not trigger system reload)
- name: Test system_wide with reload=false
ansible.posix.sysctl:
name: vm.dirty_ratio
value: 25
state: present
reload: false
system_wide: true
register: sysctl_system_wide_no_reload
- name: Validate system_wide with reload=false
ansible.builtin.assert:
that:
- sysctl_system_wide_no_reload is changed