03_upgrade.ymlยถ

---
- name: โฌ†๏ธ Nextcloud | Upgrade
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} upgrade"
  register: occ_upgrade
  changed_when: "'No upgrade required' not in occ_upgrade.stdout"
  retries: 3
  delay: 5
  until: occ_upgrade.rc == 0

- name: ๐Ÿ” Nextcloud | Read the version the upgrade left running
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} status --output=json"
  register: occ_upgraded_status
  changed_when: false

- name: ๐Ÿ” Nextcloud | Read the version the expensive repair last ran for
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} config:app:get files mimetype_version --default-value="
  register: occ_repaired_version
  changed_when: false

- name: ๐Ÿงฎ Nextcloud | Decide whether the post-upgrade pass is due
  set_fact:
    nextcloud_post_upgrade_due: >-
      {{ occ_upgraded_status.stdout
         | nextcloud_needs_post_upgrade(nextcloud_installed_version, occ_repaired_version.stdout) }}

- name: ๐Ÿ”„ Nextcloud | Post-upgrade pass
  ansible.builtin.include_tasks: 03_upgrade/01_post_upgrade.yml
  when: nextcloud_post_upgrade_due | bool

- name: ๐Ÿ”„ Nextcloud | Update the apps the daily update check found a release for
  ansible.builtin.include_tasks: 03_upgrade/02_cached_updates.yml
  when: not (nextcloud_post_upgrade_due | bool)

- name: โž• Nextcloud | Add missing columns
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-columns"
  register: occ_columns
  changed_when: "'table updated successfully' in occ_columns.stdout"

- name: โž• Nextcloud | Add missing indices
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-indices"
  register: occ_indices
  changed_when: "'table updated successfully' in occ_indices.stdout"

- name: โž• Nextcloud | Add missing primary keys
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-primary-keys"
  register: occ_pks
  changed_when: "'table updated successfully' in occ_pks.stdout"

- name: ๐Ÿ”ด Nextcloud | Disable maintenance mode
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} maintenance:mode --off"
  register: occ_maint_off
  changed_when: "'already disabled' not in occ_maint_off.stdout"
  retries: 3
  delay: 5
  until: occ_maint_off.rc == 0

- name: ๐Ÿ” Nextcloud | Read occ status
  shell: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} status --output=json"
  register: occ_status
  changed_when: false

- name: โœ… Nextcloud | Verify occ status reports the pinned major
  vars:
    occ_status_state: "{{ occ_status.stdout | nextcloud_status }}"
  assert:
    that:
      - (occ_status_state.versionstring | nextcloud_tag_major) == (NEXTCLOUD_VERSION_MAJOR | int)
      - not (occ_status_state.needsDbUpgrade | bool)
    fail_msg: >-
      occ status reports {{ occ_status_state }}, the pinned image tag is {{ NEXTCLOUD_VERSION }}.
    success_msg: >-
      occ status reports Nextcloud {{ occ_status_state.versionstring }}, the pinned major
      {{ NEXTCLOUD_VERSION_MAJOR }}.
    quiet: false