W3cubDocs

/Ansible

sysctl - Manage entries in sysctl.conf.

Synopsis

This module manipulates sysctl entries and optionally performs a /sbin/sysctl -p after changing them.

Options

parameter required default choices comments
ignoreerrors
no
  • yes
  • no
Use this option to ignore errors about unknown keys.
name
yes
The dot-separated path (aka key) specifying the sysctl variable.
aliases: key
reload
no yes
  • yes
  • no
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
no present
  • present
  • absent
Whether the entry should be present or absent in the sysctl file.
sysctl_file
no /etc/sysctl.conf
Specifies the absolute path to sysctl.conf, if not /etc/sysctl.conf.
sysctl_set
(added in 1.5)
no
  • yes
  • no
Verify token value with the sysctl command and set with -w if necessary
value
no
Desired value of the sysctl key.
aliases: val

Examples

# Set vm.swappiness to 5 in /etc/sysctl.conf
- sysctl:
    name: vm.swappiness
    value: 5
    state: present

# Remove kernel.panic entry from /etc/sysctl.conf
- sysctl:
    name: kernel.panic
    state: absent
    sysctl_file: /etc/sysctl.conf

# Set kernel.panic to 3 in /tmp/test_sysctl.conf
- sysctl: name=kernel.panic value=3 sysctl_file=/tmp/test_sysctl.conf reload=no

# Set ip forwarding on in /proc and do not reload the sysctl file
- 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
- sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes state=present reload=yes

This is a Core Module

For more information on what this means please read Core Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/sysctl_module.html