---
- name: "๐ Deploy '{{ ESPOCRM_ENTRYPOINT_SCRIPT_HOST_ABS }}'"
copy:
src: "shell/{{ ESPOCRM_ENTRYPOINT_SCRIPT_FILE }}"
dest: "{{ ESPOCRM_ENTRYPOINT_SCRIPT_HOST_ABS }}"
notify:
- compose-up
- compose-build
- name: "๐ Deploy '{{ ESPOCRM_SCRIPT_SEED_HOST_ABS }}'"
copy:
src: "php/seed/config.php"
dest: "{{ ESPOCRM_SCRIPT_SEED_HOST_ABS }}"
notify:
- compose-up
- compose-build
- name: "๐ Deploy '{{ ESPOCRM_SCRIPT_SIDECAR_HOST_ABS }}'"
copy:
src: "shell/{{ ESPOCRM_SCRIPT_SIDECAR_FILE }}"
dest: "{{ ESPOCRM_SCRIPT_SIDECAR_HOST_ABS }}"
notify:
- compose-up
- compose-build
- name: "๐ณ Docker Compose Up for '{{ application_id }}'"
meta: flush_handlers
- name: "๐งญ Resolve EspoCRM host node + local container id"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: "{{ entity_name }}"
resolve_output_prefix: ESPOCRM
resolve_compose_cid: "{{ ESPOCRM_CONTAINER }}"
- name: ๐ Check if config.php exists in EspoCRM
shell: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec --user root {{ ESPOCRM_LOCAL_CID | quote }} test -f {{ ESPOCRM_CONFIG_FILE_PRIVATE }}
register: config_file_exists
changed_when: false
failed_when: false
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: ๐ฉน Patch EspoCRM config.php
include_tasks:
file: 01_patch_config.yml
apply:
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
when: config_file_exists.rc == 0
- name: "โ
Wait until the EspoCRM data reports the image version"
ansible.builtin.shell: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec --user {{ ESPOCRM_USER }} {{ ESPOCRM_LOCAL_CID | quote }} \
sh -c 'd="$(bin/command config:get version)"; printf "%s %s\n" "$d" "$ESPOCRM_VERSION"; test "$d" = "$ESPOCRM_VERSION"'
register: espocrm_versions
changed_when: false
until: espocrm_versions.rc == 0
retries: 90
delay: 10
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: "๐ Answer siteUrl with the network sibling the request arrived on"
ansible.builtin.shell:
cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i --user {{ ESPOCRM_USER }} {{ ESPOCRM_LOCAL_CID | quote }}
sh -c 'cat >"$1.new" && if cmp -s "$1.new" "$1"; then rm "$1.new"; else mv "$1.new" "$1" && echo CHANGED; fi'
config_override {{ ESPOCRM_CONFIG_OVERRIDE_FILE | quote }}
stdin: "{{ lookup('template', 'config-override.php.j2') }}"
register: espocrm_config_override
changed_when: "'CHANGED' in espocrm_config_override.stdout"
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: โถ๏ธ Run flag setter as root (fallback)
shell: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec --user root {{ ESPOCRM_LOCAL_CID | quote }} \
php {{ ESPOCRM_SCRIPT_SEED_DOCKER }}
register: flags_result_root
changed_when: "'CHANGED' in flags_result_root.stdout"
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: ๐ฟ Flush handlers to make DB available before password reset
meta: flush_handlers
- name: ๐ชช Carry the administrator EspoCRM installed onto the declared username
ansible.builtin.shell:
cmd: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i -e ESPOCRM_ADMIN_USERNAME {{ ESPOCRM_LOCAL_CID | quote }} php
stdin: "{{ lookup('file', 'php/carry_admin_username.php') }}"
environment:
ESPOCRM_ADMIN_USERNAME: "{{ ESPOCRM_ADMIN_USERNAME }}"
register: espocrm_admin_carry
changed_when: espocrm_admin_carry.stdout is search('\[CHANGED\]')
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: ๐ Realign the administrator password EspoCRM persisted at install
ansible.builtin.shell: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i {{ ESPOCRM_LOCAL_CID | quote }} \
php command.php set-password {{ ESPOCRM_ADMIN_USERNAME | quote }}
args:
stdin: "{{ ESPOCRM_ADMIN_PASSWORD }}"
register: espocrm_admin_password
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
changed_when: espocrm_admin_password.rc == 0
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
- name: "๐ฎ Provision the group email account EspoCRM sends system mail through"
ansible.builtin.shell:
cmd: |
# nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i --user {{ ESPOCRM_USER }} {{ ESPOCRM_LOCAL_CID | quote }} php
stdin: "{{ lookup('file', 'php/seed/group_email_account.php') }}"
register: espocrm_group_email_account
changed_when: espocrm_group_email_account.stdout is search('\[CHANGED\]')
delegate_to: "{{ ESPOCRM_HOST_NODE }}"
when: lookup('email', application_id).enabled | bool
- name: "๐จ Apply the corporate design of {{ application_id }}"
ansible.builtin.include_tasks: 03_design.yml