integration_openproject_converge.ymlยถ

---
- name: ๐Ÿ” Find the stamp of the last OpenProject provisioning
  ansible.builtin.stat:
    path: "{{ NEXTCLOUD_OPENPROJECT_STAMP_FILE }}"
  register: nextcloud_op_stamp_file

- name: ๐Ÿ“– Read the stamp of the last OpenProject provisioning
  ansible.builtin.slurp:
    src: "{{ NEXTCLOUD_OPENPROJECT_STAMP_FILE }}"
  register: nextcloud_op_stamp
  when: nextcloud_op_stamp_file.stat.exists

- name: ๐Ÿงฎ Decide whether the OpenProject coupling needs a provisioning run
  set_fact:
    nextcloud_op_provision_due: >-
      {{ (lookup('config', 'web-app-nextcloud', 'addons.integration_openproject.config.rotate_oauth_client') | bool)
         or nextcloud_op_stamp is skipped
         or (nextcloud_op_stamp.content | b64decode | trim) != nextcloud_op_digest }}

- name: ๐Ÿ”ง Provision the OpenProject coupling and stamp the state it leaves
  when: nextcloud_op_provision_due | bool
  block:
    - name: ๐Ÿ”ง Converge the bidirectional OpenProject <-> Nextcloud OAuth coupling
      include_tasks: integration_openproject_provision.yml

    - name: ๐Ÿ“– Read the OpenProject coupling state the provisioning left
      include_tasks: integration_openproject_state.yml

    - name: ๐Ÿ“ Stamp the OpenProject coupling state the provisioning left
      stack_host_copy:
        content: "{{ nextcloud_op_digest }}\n"
        dest: "{{ NEXTCLOUD_OPENPROJECT_STAMP_FILE }}"
        mode: "0600"