sysctl - Manage entries in sysctl.conf.

Synopsis

Parameters

Parameter Choices/Defaults Comments
ignoreerrors
bool
    Choices:
  • no ←
  • yes
Use this option to ignore errors about unknown keys.
name
required
The dot-separated path (aka key) specifying the sysctl variable.

aliases: key
reload
bool
    Choices:
  • no
  • yes ←
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
    Choices:
  • present ←
  • absent
Whether the entry should be present or absent in the sysctl file.
sysctl_file Default:
/etc/sysctl.conf
Specifies the absolute path to sysctl.conf, if not /etc/sysctl.conf.
sysctl_set
bool

(added in 1.5)
    Choices:
  • no ←
  • yes
Verify token value with the sysctl command and set with -w if necessary
value
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

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

Maintenance

This module is flagged as core which means that it is maintained by the Ansible Core Team. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Core Team, see here.

Support

For more information about Red Hat’s support of this module, please refer to this Knowledge Base article

Author

Hint

If you notice any issues in this documentation you can edit this document to improve it.