31 Commits

Author SHA1 Message Date
softwarefactory-project-zuul[bot]
8feac41f50 Merge pull request #694 from saito-hideki/pr/backport_693
[Backport][stable-2][CI] Update AZP CI matrix and sanity test

SUMMARY

Backporting #693
Backporting #682

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-12-09 08:08:02 +00:00
saito-hideki
04274f4ce7 Ignore pylint errors caused by compatibility checks for six
* This is a temporary measure until we stop covering Python2
* Skipped sanity[cannot-ignore] to keep backward compatibility with Python2
* Consolidate all ansible-lint option locations into .ansible-lint
* Fixed some typos

Signed-off-by: saito-hideki <saito@fgrep.org>
(cherry picked from commit 9dc73a686a)
2025-12-09 07:32:44 +00:00
Hideki Saito
1bcf7f3ee4 Update AZP CI matrix and sanity test
* Update AZP CI matrix
* Add ignore file for Ansible Core 2.21
* Remove ignore lines for ansible-bad-import-from in 2.20 sanity tests

Signed-off-by: Hideki Saito <saito@fgrep.org>
(cherry picked from commit 7d5aef07e2)
2025-12-09 07:09:11 +00:00
softwarefactory-project-zuul[bot]
30db9884ce Merge pull request #674 from saito-hideki/stable-2_pr673
[Backport][stable-2][AZP] #673

SUMMARY
This PR is a backport pull request for #673 to stable-2:

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-08 00:41:00 +00:00
softwarefactory-project-zuul[bot]
d16e94f541 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-08 08:56:42 +09:00
softwarefactory-project-zuul[bot]
535167e254 Merge pull request #668 from saito-hideki/stable-2_665
[Backport][stable-2] #665

SUMMARY
Update the README with the release of Ansible Core 2.19

#665

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-07-29 05:39:58 +00:00
softwarefactory-project-zuul[bot]
6336671eba 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-29 13:28:02 +09:00
softwarefactory-project-zuul[bot]
f7ed590388 Merge pull request #667 from saito-hideki/stable-2_666
[Backport][stable-2] #666

SUMMARY
Update AZP matrix to follow ansible-test changes:

#666

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-29 01:46:42 +00:00
softwarefactory-project-zuul[bot]
07c6e38679 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-29 09:27:05 +09:00
softwarefactory-project-zuul[bot]
f6663b7511 Merge pull request #661 from saito-hideki/stable-2
[stable-2][backport][AZP] Merge pull request #660

SUMMARY
[AZP] Fixed syntax error in AZP settings

cherry-pick #660

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-17 05:28:54 +00:00
Hideki Saito
8831aa205c 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 14:01:01 +09:00
softwarefactory-project-zuul[bot]
e54b8bf68f Merge pull request #658 from saito-hideki/release_2.1.0
Release 2.1.0 commit

SUMMARY
Release 2.1.0 commit

Release Plan #149

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
This will be merged on 17 July if there are no problems

Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2025-07-17 00:01:11 +00:00
saito-hideki
d792d39716 Release 2.1.0 commit
Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-16 14:29:10 +09:00
softwarefactory-project-zuul[bot]
9d3cb96f23 Merge pull request #653 from saito-hideki/stable-2
[Backport][stable-2] #650 #654

SUMMARY
Backporting #650 to stable-2

Ref: #635

Backporting #654 to stable-2
ISSUE TYPE

Bugfix Pull Request
Feature Pull Request
CI Pull Request

COMPONENT NAME

profile_roles
profile_tasks
CI
2025-07-10 01:39:25 +00:00
softwarefactory-project-zuul[bot]
a27063e1dc 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 10:08:07 +09:00
softwarefactory-project-zuul[bot]
2351c27339 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-10 08:27:42 +09:00
softwarefactory-project-zuul[bot]
5902dcab58 Merge pull request #648 from saito-hideki/stable-2
[Backport][stable-2][AZP] Update CI Matrix

SUMMARY
Update AZP CI Matrix.

Fixes #642
Backport #640
Backport #646

ISSUE TYPE

CI tests

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-06-10 08:12:06 +00:00
softwarefactory-project-zuul[bot]
953577cdb7 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-10 16:29:58 +09:00
softwarefactory-project-zuul[bot]
59493f92aa 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-06-10 16:29:51 +09:00
softwarefactory-project-zuul[bot]
20ea2f068e Merge pull request #632 from saito-hideki/stable-2
[stable-2] Backport: #631

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 02:13:06 +00:00
softwarefactory-project-zuul[bot]
1f1d637b7f 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 10:50:09 +09:00
softwarefactory-project-zuul[bot]
7128f64169 Merge pull request #627 from saito-hideki/stable-2
[stable-2] improve mount integration tests #613 

SUMMARY
Backporting pull request for #613
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.mount

ADDITIONAL INFORMATION
None
2025-04-10 07:18:11 +00:00
softwarefactory-project-zuul[bot]
3149f38296 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 06:53:27 +00:00
softwarefactory-project-zuul[bot]
8cc459f381 Merge pull request #623 from saito-hideki/stable-2
[AZP][stable-2] Update CI test environment

SUMMARY
[AZP][stable-2] Update CI test environment

Addresses #612

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-03-31 06:08:05 +00:00
Hideki Saito
82e4990f72 [AZP][stable-2] Update CI test environment
* Addresses #612

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-03-31 05:44:37 +00:00
Abhijeet Kasurde
98f3e1255e [CI] update test containers
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2025-03-31 03:51:51 +00:00
softwarefactory-project-zuul[bot]
a004bd9494 Merge pull request #601 from saito-hideki/stable-2
Merge pull request #600 from release_2.0.0 commit

SUMMARY
Release 2.0.0 commit

Release Plan #149

ISSUE TYPE

Release Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2024-12-05 02:43:14 +00:00
softwarefactory-project-zuul[bot]
a357ceeb49 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 10:56:19 +09:00
softwarefactory-project-zuul[bot]
e8fc89fe5a Merge pull request #599 from saito-hideki/stable-2
[Backport] cherrypick #597 and #598 to stable-2 branch

SUMMARY
Merge the following two PRs to stable-2 as a cherrypick

#598
#597

ISSUE TYPE

Backport Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION
None
2024-12-03 03:47:04 +00:00
softwarefactory-project-zuul[bot]
ce72b7b1f4 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-03 12:05:23 +09:00
softwarefactory-project-zuul[bot]
f61bb76a86 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-12-03 12:04:52 +09:00
20 changed files with 156 additions and 514 deletions

View File

@@ -3,23 +3,9 @@
# 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] # 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
- sanity[cannot-ignore] # This rule is skipped to keep backward compatibility with Python 2
exclude_paths:
- changelogs/
# Enable specific rules we want to keep
enable_list:
- yaml
- name
- var-naming

View File

@@ -43,7 +43,7 @@ pool: Standard
stages:
- stage: Sanity_devel
displayName: Ansible devel sanity
displayName: Ansible devel Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
@@ -57,8 +57,23 @@ stages:
test: units
- name: Lint
test: lint
- stage: Sanity_2_20
displayName: Ansible 2.20 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.20/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_19
displayName: Ansible 2.19 sanitay & Units & Lint
displayName: Ansible 2.19 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
@@ -73,7 +88,7 @@ stages:
- name: Lint
test: lint
- stage: Sanity_2_18
displayName: Ansible 2.18 sanity & Units & Lint
displayName: Ansible 2.18 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
@@ -88,7 +103,7 @@ stages:
- name: Lint
test: lint
- stage: Sanity_2_17
displayName: Ansible 2.17 sanity & Units & Lint
displayName: Ansible 2.17 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
@@ -103,7 +118,7 @@ stages:
- name: Lint
test: lint
- stage: Sanity_2_16
displayName: Ansible 2.16 sanity & Units & Lint
displayName: Ansible 2.16 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
@@ -115,6 +130,8 @@ stages:
test: sanity
- name: Units
test: units
- name: Lint
test: lint
## Docker
- stage: Docker_devel
displayName: Docker devel
@@ -130,6 +147,20 @@ stages:
test: ubuntu2204
- name: Ubuntu 24.04
test: ubuntu2404
- stage: Docker_2_20
displayName: Docker 2.20
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.20/linux/{0}/1
targets:
- name: Fedora 42
test: fedora42
- name: Ubuntu 22.04
test: ubuntu2204
- name: Ubuntu 24.04
test: ubuntu2404
- stage: Docker_2_19
displayName: Docker 2.19
dependsOn: []
@@ -202,6 +233,22 @@ stages:
test: freebsd/14.3
- name: FreeBSD 13.5
test: freebsd/13.5
- stage: Remote_2_20
displayName: Remote 2.20
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.20/{0}/1
targets:
- name: RHEL 10.0
test: rhel/10.0
- 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
displayName: Remote 2.19
dependsOn: []
@@ -226,6 +273,8 @@ stages:
parameters:
testFormat: 2.18/{0}/1
targets:
- name: RHEL 10.0
test: rhel/10.0
- name: RHEL 9.4
test: rhel/9.4
- name: FreeBSD 13.5
@@ -238,8 +287,9 @@ stages:
parameters:
testFormat: 2.17/{0}/1
targets:
- name: RHEL 9.3
test: rhel/9.3
# 2.17 remote target doesn't have RHEL 9 image
- name: RHEL 10.0
test: rhel/10.0
- name: FreeBSD 13.5
test: freebsd/13.5
- stage: Remote_2_16
@@ -250,10 +300,9 @@ stages:
parameters:
testFormat: 2.16/{0}/1
targets:
- name: RHEL 8.8
test: rhel/8.8
- name: RHEL 9.2
test: rhel/9.2
# 2.16 remote target only has RHEL 9.6 image
- name: RHEL 9.6
test: rhel/9.6
## Finally
@@ -272,6 +321,9 @@ stages:
- Sanity_2_19
- Remote_2_19
- Docker_2_19
- Sanity_2_20
- Remote_2_20
- Docker_2_20
- Sanity_devel
- Remote_devel
- Docker_devel

View File

@@ -4,6 +4,27 @@ 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

@@ -490,3 +490,25 @@ 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

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

View File

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

View File

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

View File

@@ -1,6 +0,0 @@
---
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

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

View File

@@ -1,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)."

View File

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

View File

@@ -0,0 +1,4 @@
trivial:
- Updatng AZP CI matrix to ignore ansible-bad-import-from on six(https://github.com/ansible-collections/ansible.posix/pull/682).
- Skipped sanity[cannot-ignore] to keep backward compatibility with Python2.
- Consolidate all ansible-lint option locations into .ansible-lint file.

View File

@@ -0,0 +1,5 @@
---
trivial:
- AZP - Update AZP matrix to follow ansible-test changes.
- Add ignore file for Ansible Core 2.21.
- Remove ignore lines for ansible-bad-import-from in 2.20 sanity tests.

View File

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

View File

@@ -52,17 +52,6 @@ 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 = '''
@@ -83,15 +72,14 @@ sample output: >
'''
import collections
from datetime import datetime
import time
from ansible.module_utils.six.moves import reduce
from ansible.plugins.callback import CallbackBase
# define start time
dt0 = dtn = datetime.now().astimezone()
t0 = tn = time.time()
def secondsToStr(t):
@@ -116,18 +104,17 @@ def filled(msg, fchar="*"):
def timestamp(self):
if self.current is not None:
elapsed = (datetime.now().astimezone() - self.stats[self.current]['started']).total_seconds()
elapsed = time.time() - self.stats[self.current]['started']
self.stats[self.current]['elapsed'] += 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))
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))
class CallbackModule(CallbackBase):
@@ -147,7 +134,6 @@ class CallbackModule(CallbackBase):
self.sort_order = None
self.summary_only = None
self.task_output_limit = None
self.datetime_format = None
super(CallbackModule, self).__init__()
@@ -173,14 +159,9 @@ 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))
self._display.display(tasktime())
def _record_task(self, task):
"""
@@ -195,11 +176,10 @@ 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': dtn, 'elapsed': 0.0, 'name': task.get_name()}
self.stats[self.current] = {'started': time.time(), 'elapsed': 0.0, 'name': task.get_name()}
else:
self.stats[self.current]['started'] = dtn
self.stats[self.current]['started'] = time.time()
if self._display.verbosity >= 2:
self.stats[self.current]['path'] = task.get_path()
@@ -213,7 +193,7 @@ class CallbackModule(CallbackBase):
# Align summary report header with other callback plugin summary
self._display.banner("TASKS RECAP")
self._display.display(tasktime(self))
self._display.display(tasktime())
self._display.display(filled("", fchar="="))
timestamp(self)

View File

@@ -56,16 +56,6 @@ 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)
'''
@@ -90,13 +80,6 @@ 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
@@ -110,14 +93,6 @@ 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
'''
# ==============================================================
@@ -126,7 +101,6 @@ 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
@@ -140,30 +114,17 @@ 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
@@ -193,36 +154,19 @@ 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?
# 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":
if self.file_values[thisname] is None and self.args['state'] == "present":
self.changed = True
self.write_file = True
elif current_file_value is None and self.args['state'] == "absent":
elif self.file_values[thisname] is None and self.args['state'] == "absent":
self.changed = False
elif current_file_value and self.args['state'] == "absent":
elif self.file_values[thisname] and self.args['state'] == "absent":
self.changed = True
self.write_file = True
elif current_file_value != self.args['value']:
elif self.file_values[thisname] != self.args['value']:
self.changed = True
self.write_file = True
# with reload=yes we should check if the current system values are
@@ -355,25 +299,15 @@ class SysctlModule(object):
# https://github.com/ansible/ansible/issues/58158
return
else:
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')
# 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
@@ -403,35 +337,6 @@ 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 = []
@@ -489,8 +394,7 @@ 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'),
system_wide=dict(default=False, type='bool'), # system_wide parameter
sysctl_file=dict(default='/etc/sysctl.conf', type='path')
),
supports_check_mode=True,
required_if=[('state', 'present', ['value'])],

View File

@@ -140,8 +140,8 @@
ansible.posix.sysctl:
name: test.invalid
value: 1
ignore_errors: true
register: sysctl_test3
ignore_errors: true
- name: Debug sysctl_test3
ansible.builtin.debug:
@@ -229,91 +229,6 @@
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:
@@ -451,36 +366,3 @@
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

@@ -1,203 +0,0 @@
---
# 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

View File

@@ -0,0 +1,10 @@
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
tests/unit/mock/procenv.py pylint:ansible-bad-import-from
tests/unit/mock/yaml_helper.py pylint:ansible-bad-import-from
tests/unit/modules/conftest.py pylint:ansible-bad-import-from

View File

@@ -9,6 +9,5 @@ command -v ansible
pip install --upgrade --user pip
pip install --upgrade --user ansible-lint
PATH="${PATH/\~/${HOME}}" ansible-lint \
--exclude changelogs/ \
--profile=production
# To specify additional options, you can specify them into .ansible-lint file.
PATH="${PATH/\~/${HOME}}" ansible-lint