Nextcloud config.php with ansbile

Hi all. I have been developing an ansible role for Nextloud. For those who are familiar with ansible: the goal is that tasks are changed/run only when things change. Lets take the system settings you access with occ config:system. The config list command allows to dump the configuration as json, and according to the docs can be imported again. According to the docs, an import will add new values, update existing but leave already existing in place if not present in the import.

The php config’s values can be of type string, boolean, integer, float (the docs state float, the cli states double). There are also nested configs, like for Redis:

When it comes to configuration the nextcloud with ansible, there are problems:

  1. Using a template for config.php I do consider difficult, since it is generated at first using the system:install command. So ansible should not alter this config if not necessary
  2. Running an occ command for every setting, e.g. for Redis occ system:set redis host --value=/var /run… is not so elegant and slow
  3. The approach to generate a json file with the config that can be imported when changed, fails. The roundtrip is not possible due to the configs lilke redis. This is a bug.
  4. Finally there is a problem for config like memcache.local: '\OC\Memcache\APCu'. The backslashes are escaped “\” when using the OCC command or even stripped (OCMembacheAPCu seen in the config). This is not an ansible issue but also fails just running the commands via occ on the server directly.

I’ve not expected that nextcloud makes this job so hard. Does anyone have more experience with that or is templating this config the way to go after all?