sysctl¶
Collection Note
This module is part of the ansible.posix collection. To install the collection, use:
Added in version1.0.0.
Synopsis¶
- This module manipulates sysctl entries and optionally performs a C(/sbin/sysctl -p) after changing them.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| ignoreerrors bool |
Use this option to ignore errors about unknown keys. | |
| name str required |
The dot-separated path (also known as O(key)) specifying the sysctl variable. | |
| reload bool |
Default: True |
If V(true), performs a C(/sbin/sysctl -p) if the O(sysctl_file) is updated. If V(false), does not reload C(sysctl) even if the O(sysctl_file) is updated. |
| state str |
Default: present Choices: present, absent |
Whether the entry should be present or absent in the sysctl file. |
| sysctl_file path |
Default: /etc/sysctl.conf |
Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf). |
| sysctl_set bool |
Verify token value with the sysctl command and set with C(-w) if necessary. | |
| value str |
Desired value of the sysctl key. |
Examples¶
# Set vm.swappiness to 5 in /etc/sysctl.conf
- ansible.posix.sysctl:
name: vm.swappiness
value: '5'
state: present
# Remove kernel.panic entry from /etc/sysctl.conf
- ansible.posix.sysctl:
name: kernel.panic
state: absent
sysctl_file: /etc/sysctl.conf
# Set kernel.panic to 3 in /tmp/test_sysctl.conf
- ansible.posix.sysctl:
name: kernel.panic
value: '3'
sysctl_file: /tmp/test_sysctl.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
value: '1'
sysctl_set: true
# Set ip forwarding on in /proc and in the sysctl file and reload if necessary
- ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: true
state: present
reload: true
Authors¶
- David Chanial (@davixx)