Skip to content

linuxfabrik.lfops.nextcloud_occ_app_config

Manage a Nextcloud app configuration value via occ

Synopsis

  • Drives occ config:app:set and config:app:delete to bring a single app config key into the desired state.
  • The current value and type are read from occ config:app:get --details --output=json (or from a pre-fetched occ config:list --output=json --private listing passed via installed_config_json). occ config:app:set is only called when the stored value or type does not already match.
  • When name contains spaces, each whitespace-separated token is passed as a separate argument to occ, matching how Nextcloud addresses nested keys (e.g. name="endpoint enabled").
  • Booleans are normalized for Nextcloud's storage. value values true/1/on/yes (case-insensitive) become 1 in the database; everything else becomes 0. When reading via installed_config_json, the type is inferred from the JSON value type (Python bool/int/float/list/str), since occ config:list returns values already cast by convertTypedValue().

Available since LFOps 6.0.0.

Requirements

  • A working Nextcloud installation with the occ command available.

Mandatory Parameters

app

  • App ID whose configuration is being managed (e.g. core, files_sharing, notify_push).
  • Type: String.

name

  • Configuration key. Multiple whitespace-separated tokens are forwarded as separate arguments to occ, which is how Nextcloud addresses nested keys.
  • Type: String.

Optional Parameters

installed_config_json

  • Pre-fetched output of occ config:list --output=json --private, as either a JSON string or an already-parsed dict. When set, the module skips the config:app:get call and reads the current value from this value, which avoids running occ once per key when looping over many keys.
  • Type: Raw.

occ_path

  • Absolute path to the Nextcloud occ command.
  • Type: String.
  • Default: /var/www/html/nextcloud/occ

php_path

  • PHP binary to invoke occ with. A bare php relies on $PATH; pass an absolute path to pin a specific PHP version.
  • Type: String.
  • Default: php

state

  • present creates or updates the key, absent deletes it.
  • Type: String. One of absent, present.
  • Default: present

type

  • Data type occ config:app:set records for the value.
  • Type: String. One of string, integer, float, boolean, array.
  • Default: string

value

  • Target value for the configuration key. Required when state=C(present). When type=C(array), pass a valid JSON array literal; this module forwards the string verbatim and lets occ parse it.
  • Type: String.

Examples

- name: 'Set an app configuration value'
  linuxfabrik.lfops.nextcloud_occ_app_config:
    app: 'core'
    name: 'shareapi_expire_after_n_days'
    value: 90
    type: 'integer'
    occ_path: '/data/nextcloud/occ'
    php_path: '/usr/bin/php'

Return Values

changed

  • Whether the value or type had to be changed.
  • Type: Bool.
  • Returned: always.

current_type

  • Stored type before any changes were applied. Empty string when the key did not exist.
  • Type: String.
  • Returned: always.

current_value

  • Stored value (as a string) before any changes were applied. Empty string when the key did not exist. Booleans are normalized to 1/0 to match how Nextcloud stores them.
  • Type: String.
  • Returned: always.

rc

  • Exit code of the occ config:app:set or config:app:delete command.
  • Type: Number.
  • Returned: when changed and not in check mode.

stderr

  • Standard error of the occ config:app:set or config:app:delete command.
  • Type: String.
  • Returned: when changed and not in check mode.

stdout

  • Standard output of the occ config:app:set or config:app:delete command.
  • Type: String.
  • Returned: when changed and not in check mode.

Authors

  • Linuxfabrik GmbH, Zurich, Switzerland, https://www.linuxfabrik.ch