Ansible sysctl Module: Manage Kernel Parameters (Complete Guide)
By Luca Berton · Published 2024-01-01 · Category: security-compliance
How to use Ansible sysctl module to set kernel parameters. Configure networking, memory, security settings. Persist changes in sysctl.conf with examples.
Ansible sysctl Module: Manage Kernel Parameters (Complete Guide)
The ansible.builtin.sysctl module manage kernel parameters at runtime. This guide covers all common use cases with practical playbook examples.
Set a Kernel Parameter
Network Performance Tuning
Security Hardening
Memory Settings
FAQ
How do I set kernel parameters in Ansible?
Use ansible.builtin.sysctl with name and value. Set sysctl_set: true to apply immediately and state: present to persist in /etc/sysctl.conf.
Are sysctl changes persistent across reboots?
Yes, when state: present is used, Ansible writes to /etc/sysctl.conf (or sysctl.d/). Set reload: true to also apply the change immediately.
Conclusion
The ansible.builtin.sysctl module is a versatile tool for manage kernel parameters at runtime. Use the examples above as starting points and adapt them to your infrastructure needs.
Related Articles • Ansible Security Hardening Guide • Ansible service Module
Category: security-compliance