---
- name: "π Resolve the node that holds the Penpot backend and its local id"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: "{{ PENPOT_BACKEND_SERVICE }}"
resolve_output_prefix: PENPOT_BACKEND
resolve_compose_cid: "{{ PENPOT_BACKEND_CONTAINER_ADDRESS }}"
- name: "π₯Ύ Bootstrap the Penpot administrator's local account (idempotent)"
ansible.builtin.shell:
cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i {{ PENPOT_BACKEND_LOCAL_CID | quote }}
python3 manage.py create-profile
-n {{ PENPOT_ADMIN_FULLNAME | quote }}
-e {{ PENPOT_ADMIN_EMAIL | quote }}
stdin: "{{ PENPOT_ADMIN_PASSWORD }}"
register: penpot_admin_create
retries: 30
delay: 5
until: >-
penpot_admin_create.rc == 0 or
('already exists' in (penpot_admin_create.stdout | default('') ~ penpot_admin_create.stderr | default('')))
changed_when: "'Created' in penpot_admin_create.stdout"
failed_when:
- penpot_admin_create.rc != 0
- "'already exists' not in (penpot_admin_create.stdout | default('') ~ penpot_admin_create.stderr | default(''))"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
delegate_to: "{{ PENPOT_BACKEND_HOST_NODE }}"
- name: "π§ Set the Penpot administrator's local password when the profile already exists"
ansible.builtin.shell:
cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i {{ PENPOT_BACKEND_LOCAL_CID | quote }}
python3 manage.py update-profile
-e {{ PENPOT_ADMIN_EMAIL | quote }}
stdin: "{{ PENPOT_ADMIN_PASSWORD }}"
when: "'already exists' in (penpot_admin_create.stdout | default('') ~ penpot_admin_create.stderr | default(''))"
register: penpot_admin_update
changed_when: "'Updated' in penpot_admin_update.stdout"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
delegate_to: "{{ PENPOT_BACKEND_HOST_NODE }}"