integration_suitecrm_provision.ymlΒΆ

---
- name: ⏳ Wait for the SuiteCRM web endpoint
  wait_for:
    host: "{{ DOCKER_REACH_HOST }}"
    port: "{{ lookup('config', 'web-app-suitecrm', 'services.suitecrm.ports.local.http') }}"
    delay: 5
    timeout: "{{ lookup('timeout', 600) | int }}"

- name: πŸ”§ Provision SuiteCRM OAuth2 password client (idempotent), capture credentials
  ansible.builtin.command:
    argv:
      - container
      - exec
      - -i
      - -e
      - "NC_CLIENT_NAME={{ nextcloud_crm_client_name }}"
      - -e
      - NC_CLIENT_SECRET
      - "{{ nextcloud_crm_container }}" # nocheck: container-exec-resolver  runs only behind the bare-name partner probe gate, compose co-location
      - php
      - -d
      - error_reporting=E_ERROR
      - -
    chdir: "{{ nextcloud_crm_instance_dir }}"
    stdin: "{{ lookup('file', 'php/addons/suitecrm/provision_oauth_password_client.php') }}"
  environment:
    NC_CLIENT_SECRET: "{{ nextcloud_crm_client_secret }}"
  register: nextcloud_crm_provision
  changed_when: false
  no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"

- name: πŸ”Ž Parse the SuiteCRM OAuth client credentials
  set_fact:
    nextcloud_crm_client_id: "{{ nextcloud_crm_provision.stdout | regex_search('CLIENT_ID=(.+)', '\\1') | first }}"
  no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"

- name: πŸ”— Link the SuiteCRM OAuth password client into integration_suitecrm
  ansible.builtin.shell:
    cmd: "{{ NEXTCLOUD_DOCKER_EXEC_INTERACTIVE }} sh -s"
    stdin: |
      set -eu
      {{ NEXTCLOUD_INTERNAL_OCC_COMMAND | quote }} config:app:set integration_suitecrm oauth_instance_url --value={{ nextcloud_crm_base_url | quote }}
      {{ NEXTCLOUD_INTERNAL_OCC_COMMAND | quote }} config:app:set integration_suitecrm client_id --value={{ nextcloud_crm_client_id | quote }}
      {{ NEXTCLOUD_INTERNAL_OCC_COMMAND | quote }} config:app:set integration_suitecrm client_secret --value={{ nextcloud_crm_client_secret | quote }}
  no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"