AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Configuring Kernel Parameters in RedHat-like Linux Systems with Ansible System Role — Video Tutorial
Learn how to configure kernel parameters in RedHat-like Linux systems using the Ansible System Role.
What You'll Learn
- Ansible Configure Kernel Parameters in RedHat-like systems
- Links
- code
- execution
- idempotency
- Verification
- Conclusion
- Related Articles
- See also
Full Tutorial Content
How to Configure Kernel Parameters in RedHat-like Linux systems with Ansible using system role?
I'm going to show you a live Playbook with some simple Ansible code.
I'm Luca Berton and welcome to today's episode of Ansible Pilot.
Ansible Configure Kernel Parameters in RedHat-like systems
- `linux-system-roles` Fedora, Enterprise Linux & CentOS
- `rhel-system-roles` package Red Hat Enterprise Linux
Today we're talking about `linux-system-role`.
This is a swiss army that you need to absolutely add to your IT knowledge.
Currently, there are 21 roles to configure a lot of system properties.
The roles are developed and tested for RedHat-like systems but the project might expand in the future.
It's available as a package named `linux-system-role` for Fedora, Enterprise Linux, and CentOS.
In Red Hat Enterprise Linux is named `rhel-system-roles` and is available since RHEL 8.
If you would like to know more about the available roles and jump immediately to the Ansible Galaxy page or the official website.
Links
- https://galaxy.ansible.com/linux-system-roles
- https://linux-system-roles.github.io/
## Playbook
Configure Kernel Parameters in RedHat-like Linux systems with Ansible System Role
code
```yaml
---
- name: kernel_settings Playbook
hosts: all
become: true
vars:
kernel_settings_sysctrl:
- name: fs.file-max
value: 400000
- name: kernel.threads-max
value: 65536
kernel_settings_sysfs:
- name: /sys/class/net/lo/mtu
value: 65000
kernel_settings_transparent_hugepages: madvise
roles:
- linux-system-roles.kernel_settings
```
execution
```bash
$ ansible-playbook -i inventory kernel_settings.yml
PLAY [kernel_settings Playbook] ***********************************************************************
TASK [Gathering Facts] ****************************************************************************
[DEPRECATION WARNING]: Distribution fedora 35 on host fedora.example.com should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible
releases. A future Ansible release will default to using the discovered platform python for this
host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for
more information. This feature will be removed in version 2.12. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [fedora.example.com]
TASK [linux-system-roles.kernel_settings : Set version specific variables] ************************
ok: [fedora.example.com]
TASK [linux-system-roles.kernel_settings : Ensure required packages are installed] ****************
ok: [fedora.example.com]
TASK [linux-system-roles.kernel_settings : Ensure required services are enabled and started] ******
ok: [fedora.example.com] => (item=tuned)
TASK [linux-system-roles.kernel_settings : Ensure kernel settings profile directory exists] *******
ok: [fedora.example.com]
TASK [linux-system-roles.kernel_settin
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 4 min
- Category: installation
Read the full written article: Configuring Kernel Parameters in RedHat-like Linux Systems with Ansible System Role