Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for --system Option in Sysctl Module #544

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MubashirUsman
Copy link

SUMMARY

Sysctl module does not currently support the --system option, which loads the configuration files from directories in the following order.
/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

I defined SYSCTL_DIRS, list of directories to iterate over if system_wide parameter is set to true. It acts same as sysctl -p <config-file>, and goes over all the paths defined in SYSCTL_DIRS.
Fixes #512

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ansible.posix.sysctl

ADDITIONAL INFORMATION

Copy link
Contributor

@MaKaNu
Copy link

MaKaNu commented Sep 16, 2024

What is the status of this PR?

I am also at that point.

Copy link
Collaborator

@saito-hideki saito-hideki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! :)
As far as I know, sysctlmodule adds or removes the sysctl parameters specified by the name parameter (which is required) to/from the configuration file specified by sysctl_file, and if the reload option is set to true, it will reload the file.

The system_wide option in this PR reloads not only the modified file but other files as well. Is this functionality truly necessary?
If the intention is simply to reload all configuration files, similar to sysctl --system, I believe it would be necessary to change the name parameter from required to optional.

@saito-hideki saito-hideki added needs_info verified This issue has been verified/reproduced by maintainer labels Sep 26, 2024
@MaKaNu
Copy link

MaKaNu commented Sep 26, 2024

The system_wide option in this PR reloads not only the modified file but other files as well. Is this functionality truly necessary?

From the ubuntu man page:

--system
Load settings from all system configuration files. Files are read from directories
in the following list in given order from top to bottom. Once a file of a given
filename is loaded, any file of the same name in subsequent directories is ignored.
/run/sysctl.d/.conf
/etc/sysctl.d/
.conf
/usr/local/lib/sysctl.d/.conf
/usr/lib/sysctl.d/
.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf

@saito-hideki
Copy link
Collaborator

saito-hideki commented Sep 27, 2024

@MubashirUsman
Thank you for the update :)

From the ubuntu man page

As mentioned in the man page you pointed out, --system option changes the basic behavior of the sysctl module, which defines sysctl parameters in a specific file and reflects the values by reloading only that file. I was concerned about that point.
So, I would like to know the specific use cases that require this function.
The typical use case would be to set several parameters in multiple files and then reload all the files with sysctl --system to apply the changes all at once.
However, sysctl module applies one parameter to one file per task. Therefore I simply thought that the typical bulk application mentioned above might be better handled using the shell module or similar. I'd like to hear your thoughts on this.

Copy link
Contributor

@MubashirUsman
Copy link
Author

MubashirUsman commented Oct 15, 2024

I needed to reload two files in different directories and had to use the shell module, sysctl --system to make the changes take effect. Using this, the name parameter won't be needed and can be made optional.
I was setting up the Kubernetes cluster when I had to set module parameters and load overlay and br_netfilter kernal modules in different files.

@MaKaNu
Copy link

MaKaNu commented Oct 16, 2024

I needed to reload two files in different directories and had to use the shell module, sysctl --system to make the changes take effect. Using this, the name parameter won't be needed and can be made optional. I was setting up the Kubernetes cluster when I had to set module parameters and load overlay and br_netfilter kernal modules in different files.

Same approach here. Was setting up a kubernetes Cluster.

@saito-hideki
Copy link
Collaborator

saito-hideki commented Oct 22, 2024

@MubashirUsman @MaKaNu thank you for your valuable feedback :)
This PR changes past behavior, so it cannot be backported to stable-1, but I agree to merge it into the main branch.

@MubashirUsman could you add some integration tests for this change and create a changelog/fragments file?
You can see more details about the changelog:

Copy link
Contributor

Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_info verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sysctl --system
3 participants