From 7d7dda60617c170255b3996e32cdfd1216c74774 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 20 Dec 2021 22:17:14 -0600 Subject: [PATCH] r/nextcloud: Dynamically set version in config Nextcloud thinks it needs to run the upgrade/migration tool if the version number in its configuration file does not match the running version. It then updates the config file with the correct version. The next time the configuration policy is applied, however, the version will revert back to whatever is set in the template. This will re-trigger the upgrade notification. To avoid this problem, we now set the version in the configuration file dynamically. Nextcloud writes its version number in a constant in `version.php`. --- roles/nextcloud/tasks/main.yml | 15 +++++++++++++++ roles/nextcloud/templates/config.php.j2 | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 98adc2d..213da0b 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -12,6 +12,21 @@ tags: - install +- name: check nextcloud version + command: >- + php -r 'require "/usr/share/nextcloud/version.php"; + echo join(".", $OC_Version);' + check_mode: false + changed_when: false + register: check_nc_version + tags: + - always +- name: set nc_version fact + set_fact: + nc_version: '{{ check_nc_version.stdout }}' + tags: + - always + - name: ensure nextcloud database user exists become: true become_user: postgres diff --git a/roles/nextcloud/templates/config.php.j2 b/roles/nextcloud/templates/config.php.j2 index a1966cd..f3c3a68 100644 --- a/roles/nextcloud/templates/config.php.j2 +++ b/roles/nextcloud/templates/config.php.j2 @@ -35,7 +35,7 @@ $CONFIG = array ( ), 'datadirectory' => '/var/lib/nextcloud/data', 'dbtype' => 'pgsql', - 'version' => '20.0.8.1', + 'version' => '{{ nc_version }}', 'overwrite.cli.url' => 'https://{{ nextcloud_server_name }}', 'dbname' => 'nextcloud', 'dbhost' => 'localhost',