community.openwrt.sysctl module – Manage sysctl entries on OpenWrt targets

Note

This module is part of the community.openwrt collection (version 1.1.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.openwrt.

To use it in a playbook, specify: community.openwrt.sysctl.

Synopsis

  • The community.openwrt.sysctl module manages sysctl configuration on OpenWrt systems.

  • It can modify both the running kernel parameters and the persistent configuration file.

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

ignore_errors

aliases: ignoreerrors

boolean

Ignore errors when the sysctl key is unknown.

Choices:

  • false

  • true

name

aliases: key

string / required

The sysctl key to manage.

reload

boolean

Whether to reload the sysctl configuration after making changes.

Only applies when state=present.

Choices:

  • false

  • true ← (default)

state

string

Whether the sysctl entry should be present or absent in the configuration file.

Choices:

  • "absent"

  • "present" ← (default)

sysctl_file

string

The sysctl configuration file to modify.

Default: "/etc/sysctl.conf"

sysctl_set

boolean

Whether to set the value in the running kernel.

If false, only the configuration file is modified.

Choices:

  • false ← (default)

  • true

value

aliases: val

string

The value to set for the sysctl key.

Required when state=present.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

platform

Platform: OpenWrt

Target platform for this module.

Examples

- name: Enable IP forwarding
  community.openwrt.sysctl:
    name: net.ipv4.ip_forward
    value: '1'
    state: present

- name: Set kernel parameter and apply immediately
  community.openwrt.sysctl:
    name: net.ipv4.tcp_syncookies
    value: '1'
    sysctl_set: true

- name: Remove a sysctl entry
  community.openwrt.sysctl:
    name: net.ipv6.conf.all.forwarding
    state: absent

- name: Set value without reloading
  community.openwrt.sysctl:
    name: vm.swappiness
    value: '10'
    reload: false

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

name

string

The sysctl key that was managed.

Returned: always

Sample: "net.ipv4.ip_forward"

value

string

The value of the sysctl key.

Returned: when state=present

Sample: "1"

Authors

  • Markus Weippert (@gekmihesg)