---
- name: "π Resolve {{ application_id }} hosting node + container id"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: gitea
resolve_output_prefix: GITEA
resolve_compose_cid: "{{ GITEA_CONTAINER_ADDRESS }}"
- name: "β³ Wait until Gitea has migrated its database and serves the API"
ansible.builtin.shell: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec {{ GITEA_LOCAL_CID | quote }}
{{ 10 | curl(retries=0) }} -fS -o /dev/null {{ GITEA_LOOPBACK_VERSION_URL | quote }}
delegate_to: "{{ GITEA_HOST_NODE }}"
register: gitea_ready
changed_when: false
retries: "{{ ((lookup('timeout', 600) | int) / 5) | round(0, 'ceil') | int }}"
delay: 5
until: gitea_ready.rc == 0
- name: "π Create initial admin user"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i -e GITEA_ADMIN_PASSWORD --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
/app/gitea/gitea admin user create \
--admin \
--username "{{ lookup('users', 'platform_administrator').username }}" \
--password "$GITEA_ADMIN_PASSWORD" \
--email "{{ lookup('users', 'platform_administrator').email }}" \
--must-change-password=false \
-c {{ GITEA_CONFIG }}
'
environment:
GITEA_ADMIN_PASSWORD: "{{ lookup('users', 'platform_administrator').password }}"
delegate_to: "{{ GITEA_HOST_NODE }}"
register: create_admin
changed_when: "'has been successfully created' in create_admin.stdout"
failed_when: create_admin.rc != 0 and 'user already exists' not in create_admin.stderr
- name: "π Realign the administrator password Gitea persisted at install"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i -e GITEA_ADMIN_PASSWORD --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
/app/gitea/gitea admin user change-password \
--username "{{ lookup('users', 'platform_administrator').username }}" \
--password "$GITEA_ADMIN_PASSWORD" \
--must-change-password=false \
-c {{ GITEA_CONFIG }}
'
environment:
GITEA_ADMIN_PASSWORD: "{{ lookup('users', 'platform_administrator').password }}"
delegate_to: "{{ GITEA_HOST_NODE }}"
changed_when: true
- name: βΆοΈ Execute Setup Routines
include_tasks: 02_setup.yml
- name: βΆοΈ Execute Cleanup Routines
include_tasks: 03_cleanup.yml
when: MODE_CLEANUP | bool
- name: "π Provision the MCP surface"
include_tasks: utils/mcp.yml
when: GITEA_MCP_ENABLED | bool
- name: π Include DNS role to register Gitea domain(s)
include_role:
name: sys-dns-cloudflare-records
vars:
cloudflare_records:
- zone: "{{ lookup('domain',application_id) | to_zone }}"
type: A
name: "{{ lookup('domain',application_id) }}"
content: "{{ networks.internet.ip4 }}"
proxied: false
when: DNS_PROVIDER == 'cloudflare'