Files
computer-playbook/roles/web-app-gitlab/tasks/utils/root_password.yml
T
kevinveenbirkenbachandClaude Opus 5 23e642a3f3 fix(roles): realign the admin password on every deploy, not only at install
3c72c2002a and 5366788ab1 moved application roles from the host account
administrator onto platform_administrator. administrator never rotates: it
declares ansible_become_password in roles/user-administrator/meta/users.yml, so
the generator pins nothing into host_vars, and rotate.py:12 exempts it anyway.
platform_administrator rotates with every --users pass, between PASS 1 and
PASS 2 of a matrix-deploy round. The roles below wrote the password only when
they created the account, so from the second pass on the instance kept the
previous value while the deploy rendered the new one, and the sign-in failed.

Each one now re-applies the declared password through its own handle. baserow
drops the 'if created' guard and compares with check_password. gitea and
mattermost gain a change-password call beside the create they already had.
gitlab realigns its native root break-glass through the Rails runner and clears
password_automatically_set, which would otherwise make valid_password? return
false whatever the password is. magento and snipe-it get a script because
neither ships a CLI for an existing account; magento's runs under AREA_GLOBAL so
the adminhtml-only admin_user_save_after observer never loads, at the price of
the admin_passwords history row. matomo moves its realign out from behind the
token gate a rotation never opens. The matrix ansible flavor gets the realign
its compose flavor already had. bluesky resets the native PDS account through
the admin API when the create reports the handle taken.

Every new path follows the contract web-app-nextcloud and sys-svc-rdbms already
use: [CHANGED] / [UNCHANGED] / [FAIL] on the wire, failed_when on rc or [FAIL],
and an absent account is a failure rather than a silent zero-row success. The
password reaches the container through container exec -e NAME plus a task
environment, never the host-side argv.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-12 21:21:57 +02:00

35 lines
1.3 KiB
YAML

---
- name: "🔍 Resolve the node and container id running the GitLab Rails app"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: "{{ GITLAB_WEBSERVICE_SERVICE_NAME }}"
resolve_output_prefix: GITLAB_RAILS
resolve_compose_cid: "{{ lookup('container_address', application_id, GITLAB_WEBSERVICE_SERVICE_NAME) }}"
- name: "🔑 Realign the root password GitLab seeded on the empty database"
ansible.builtin.command:
argv:
- container
- exec
- -i
- -e
- GITLAB_ROOT_USERNAME
- -e
- GITLAB_ROOT_PASSWORD
- "{{ GITLAB_RAILS_LOCAL_CID }}" # nocheck: container-exec-resolver
- "{{ GITLAB_RAILS_BIN }}"
- runner
- "-"
stdin: "{{ lookup('file', 'ruby/realign_root_password.rb') }}"
environment:
GITLAB_ROOT_USERNAME: "{{ GITLAB_ROOT_USERNAME }}"
GITLAB_ROOT_PASSWORD: "{{ GITLAB_INIT_ROOT_PASSWORD }}"
register: gitlab_root_realign
changed_when: gitlab_root_realign.stdout is search('\[CHANGED\]')
failed_when: >-
gitlab_root_realign.rc != 0
or gitlab_root_realign.stdout is search('\[FAIL\]')
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
delegate_to: "{{ GITLAB_RAILS_HOST_NODE }}"
run_once: true