ansible.posix.sysctl – Manage entries in sysctl.conf.
Note
This plugin is part of the ansible.posix collection (version 1.1.1).
To install it use: ansible-galaxy collection install ansible.posix.
To use it in a playbook, specify: ansible.posix.sysctl.
New in version 1.0.0: of ansible.posix
Synopsis
- This module manipulates sysctl entries and optionally performs a
/sbin/sysctl -pafter changing them.
Parameters
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| ignoreerrors boolean |
| Use this option to ignore errors about unknown keys. |
| name string / required | The dot-separated path (aka key) specifying the sysctl variable. aliases: key | |
| reload boolean |
| If yes, performs a /sbin/sysctl -p if the sysctl_file is updated. If no, does not reload sysctl even if the sysctl_file is updated. |
| state string |
| Whether the entry should be present or absent in the sysctl file. |
| sysctl_file string | Default: "/etc/sysctl.conf" | Specifies the absolute path to sysctl.conf, if not /etc/sysctl.conf. |
| sysctl_set boolean |
| Verify token value with the sysctl command and set with -w if necessary |
| value string | Desired value of the sysctl key. aliases: val |
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: no
# 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: yes
# 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: yes
state: present
reload: yes
Authors
- David CHANIAL (@davixx) <david.chanial@gmail.com>
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/ansible/posix/sysctl_module.html