Este conteúdo não está disponível no idioma selecionado.
Chapter 14. Configuring kernel parameters permanently by using RHEL system roles
You can use the kernel_settings
RHEL system role to configure kernel parameters on multiple clients at once. This solution:
- Provides a friendly interface with efficient input setting.
- Keeps all intended kernel parameters in one place.
After you run the kernel_settings
role from the control machine, the kernel parameters are applied to the managed systems immediately and persist across reboots.
Note that RHEL system role delivered over RHEL channels are available to RHEL customers as an RPM package in the default AppStream repository. RHEL system role are also available as a collection to customers with Ansible subscriptions over Ansible Automation Hub.
14.1. Applying selected kernel parameters by using the kernel_settings RHEL system role Copiar o linkLink copiado para a área de transferência!
You can use the kernel_settings
RHEL system role to remotely configure various kernel parameters across multiple managed operating systems with persistent effects. For example, you can configure:
- Transparent hugepages to increase performance by reducing the overhead of managing smaller pages.
- The largest packet sizes are to be transmitted over the network with the loopback interface.
- Limits on files, which can be opened simultaneously.
Prerequisites
- You have prepared the control node and the managed nodes.
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them.
Procedure
Create a playbook file, for example,
~/playbook.yml
, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The settings specified in the example playbook include the following:
kernel_settings_sysfs: <list_of_sysctl_settings>
-
A YAML list of
sysctl
settings and the values you want to assign to these settings. kernel_settings_transparent_hugepages: <value>
-
Controls the memory subsystem Transparent Huge Pages (THP) setting. You can disable THP support (
never
), enable it system wide (always
) or insideMAD_HUGEPAGE
regions (madvise
). kernel_settings_reboot_ok: <true|false>
The default is
false
. If set totrue
, the system role will determine if a reboot of the managed host is necessary for the requested changes to take effect and reboot it. If set tofalse
, the role will return the variablekernel_settings_reboot_required
with a value oftrue
, indicating that a reboot is required. In this case, a user must reboot the managed node manually.For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.kdump/README.md
file on the control node.
Validate the playbook syntax:
ansible-playbook --syntax-check ~/playbook.yml
$ ansible-playbook --syntax-check ~/playbook.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
ansible-playbook ~/playbook.yml
$ ansible-playbook ~/playbook.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify the affected kernel parameters:
ansible managed-node-01.example.com -m command -a 'sysctl fs.file-max kernel.threads-max net.ipv6.conf.lo.mtu' ansible managed-node-01.example.com -m command -a 'cat /sys/kernel/mm/transparent_hugepage/enabled'
# ansible managed-node-01.example.com -m command -a 'sysctl fs.file-max kernel.threads-max net.ipv6.conf.lo.mtu' # ansible managed-node-01.example.com -m command -a 'cat /sys/kernel/mm/transparent_hugepage/enabled'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow