community.general.sysrc module – Manage FreeBSD using sysrc

Note

This module is part of the community.general collection (version 5.4.0).

You might already have this collection installed if you are using the ansible package. 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.general.

To use it in a playbook, specify: community.general.sysrc.

New in version 2.0.0: of community.general

Synopsis

  • Manages /etc/rc.conf for FreeBSD.

Parameters

Parameter

Comments

delim

string

Delimiter to be used instead of .

Only used when state=value_present or state=value_absent.

Default: ” “

jail

string

Name or ID of the jail to operate on.

name

string / required

Name of variable in /etc/rc.conf to manage.

path

string

Path to file to use instead of /etc/rc.conf.

Default: “/etc/rc.conf”

state

string

Use present to add the variable.

Use absent to remove the variable.

Use value_present to add the value to the existing variable.

Use value_absent to remove the value from the existing variable.

Choices:

  • absent

  • present ← (default)

  • value_present

  • value_absent

value

string

The value to set when state=present.

The value to add when state=value_present.

The value to remove when state=value_absent.

Notes

Note

  • The name cannot contain periods as sysrc does not support OID style names.

Examples

---
# enable mysql in the /etc/rc.conf
- name: Configure mysql pid file
  community.general.sysrc:
    name: mysql_pidfile
    value: "/var/run/mysqld/mysqld.pid"

# enable accf_http kld in the boot loader
- name: Enable accf_http kld
  community.general.sysrc:
    name: accf_http_load
    state: present
    value: "YES"
    path: /boot/loader.conf

# add gif0 to cloned_interfaces
- name: Add gif0 interface
  community.general.sysrc:
    name: cloned_interfaces
    state: value_present
    value: "gif0"

# enable nginx on a jail
- name: Enable nginx in test jail
  community.general.sysrc:
    name: nginx_enable
    value: "YES"
    jail: testjail

Return Values

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

Key

Description

changed

boolean

Return changed for sysrc actions.

Returned: always

Sample: true

Authors

  • David Lundgren (@dlundgren)