01_manager_ops.ymlΒΆ

---
- name: "πŸš€ Deploy PHP error configuration (env aware)"
  stack_host_template:
    src: "php.ini.j2"
    dest: "{{ SUITECRM_PHP_CONFIG_HOST }}"
  notify:
    - compose-up

- name: "🌐 Render the SITE_URL of the network sibling a request arrives on"
  stack_host_template:
    src: "site_url.php.j2"
    dest: "{{ SUITECRM_SITE_URL_SCRIPT_HOST }}"
  notify:
    - compose-up

- name: "πŸ“„ Render SuiteCRM LDAP mapping"
  stack_host_template:
    src: "ldap.yaml.j2"
    dest: "{{ SUITECRM_LDAP_CONFIG_HOST }}"
  when: SUITECRM_LDAP_ENABLED | bool
  notify:
    - compose-up

- name: "πŸ“„ Deploy SuiteCRM session handler wiring"
  stack_host_copy:
    src: "session.yaml"
    dest: "{{ SUITECRM_SESSION_CONFIG_HOST }}"
    mode: "0444"
  notify:
    - compose-up

- name: "πŸš€ Deploy '{{ SUITECRM_ENTRYPOINT_SCRIPT_HOST_ABS }}'"
  copy:
    src: "{{ SUITECRM_ENTRYPOINT_SCRIPT_SRC }}"
    dest: "{{ SUITECRM_ENTRYPOINT_SCRIPT_HOST_ABS }}"
  notify:
    - compose-up
    - compose-build

- name: "πŸš€ Deploy '{{ SUITECRM_EXTERNAL_AUTH_PATCH_HOST_ABS }}'"
  copy:
    src: "{{ SUITECRM_EXTERNAL_AUTH_PATCH_SRC }}"
    dest: "{{ SUITECRM_EXTERNAL_AUTH_PATCH_HOST_ABS }}"
  notify:
    - compose-up
    - compose-build

- name: "🐳 Docker Compose Up for '{{ application_id }}'"
  meta: flush_handlers

- name: "⏳ Wait until the SuiteCRM container is healthy"
  shell: >
    container inspect --type container --format '{% raw %}{{.State.Health.Status}}{% endraw %}' {{ SUITECRM_CONTAINER_ADDRESS }}
  register: suitecrm_health
  changed_when: false
  until: suitecrm_health.stdout.strip() == "healthy"
  retries: 300
  delay: 5

- name: "πŸ”‘ Ensure the SuiteCRM administrator exists and accepts the declared password"
  ansible.builtin.shell:
    cmd: >-
      container exec -i --user {{ SUITECRM_WEB_USER }}
      -e SUITECRM_REALIGN_USERNAME -e SUITECRM_REALIGN_PASSWORD -e SUITECRM_REALIGN_EMAIL
      {{ SUITECRM_CONTAINER_ADDRESS }} php
    stdin: "{{ lookup('file', 'php/realign_admin_password.php') }}"
  environment:
    SUITECRM_REALIGN_USERNAME: "{{ SUITECRM_ADMIN_USERNAME }}"
    SUITECRM_REALIGN_PASSWORD: "{{ SUITECRM_ADMIN_PASSWORD }}"
    SUITECRM_REALIGN_EMAIL: "{{ SUITECRM_ADMIN_EMAIL }}"
  register: suitecrm_admin_password_realign
  changed_when: suitecrm_admin_password_realign.stdout is search('\[CHANGED\]')
  failed_when: >-
    suitecrm_admin_password_realign.rc != 0
    or suitecrm_admin_password_realign.stdout is search('\[FAIL\]')
  no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"

- name: "πŸ”Ž List SuiteCRM log paths the web user cannot write"
  shell: >
    container exec --user {{ SUITECRM_WEB_USER }} {{ SUITECRM_CONTAINER_ADDRESS }}
    find {{ SUITECRM_APP_DIR }}/logs ! -writable
  register: suitecrm_unwritable_logs
  changed_when: false
  failed_when: suitecrm_unwritable_logs.rc != 0 or suitecrm_unwritable_logs.stdout | length > 0