community.general.sysrc (8.5.0) — module

Manage FreeBSD using sysrc

| "added in version" 2.0.0 of community.general"

Authors: David Lundgren (@dlundgren)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manages C(/etc/rc.conf) for FreeBSD.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
# enable mysql in the /etc/rc.conf
- name: Configure mysql pid file
  community.general.sysrc:
    name: mysql_pidfile
    value: "/var/run/mysqld/mysqld.pid"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# add gif0 to cloned_interfaces
- name: Add gif0 interface
  community.general.sysrc:
    name: cloned_interfaces
    state: value_present
    value: "gif0"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# enable nginx on a jail
- name: Enable nginx in test jail
  community.general.sysrc:
    name: nginx_enable
    value: "YES"
    jail: testjail

Inputs

    
jail:
    description:
    - Name or ID of the jail to operate on.
    type: str

name:
    description:
    - Name of variable in C(/etc/rc.conf) to manage.
    required: true
    type: str

path:
    default: /etc/rc.conf
    description:
    - Path to file to use instead of V(/etc/rc.conf).
    type: str

delim:
    default: ' '
    description:
    - Delimiter to be used instead of V(" ") (space).
    - Only used when O(state=value_present) or O(state=value_absent).
    type: str

state:
    choices:
    - absent
    - present
    - value_present
    - value_absent
    default: present
    description:
    - Use V(present) to add the variable.
    - Use V(absent) to remove the variable.
    - Use V(value_present) to add the value to the existing variable.
    - Use V(value_absent) to remove the value from the existing variable.
    type: str

value:
    description:
    - The value to set when O(state=present).
    - The value to add when O(state=value_present).
    - The value to remove when O(state=value_absent).
    type: str

Outputs

changed:
  description: Return changed for sysrc actions.
  returned: always
  sample: true
  type: bool