mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 23:08:06 +02:00
web-app-taiga: extract admin bootstrap into dedicated task; add robust upsert path
Add roles/web-app-taiga/tasks/01_administrator.yml to handle admin creation via 'createsuperuser' and, on failure, an upsert fallback using 'manage.py shell'. Ensures email, is_staff, is_superuser, is_active are set and password is updated when needed; emits CHANGED marker for idempotence. Update roles/web-app-taiga/tasks/main.yml to include the new 01_administrator.yml task file, removing the inline admin logic for better separation of concerns. Uses taiga-manage helper service and composes docker-compose.yml with docker-compose-inits.yml to inherit env/networks/volumes consistently. Chat reference: https://chatgpt.com/share/68af7637-225c-800f-b670-2b948f5dea54
This commit is contained in:
@@ -22,26 +22,5 @@
|
||||
- name: "Flush Taiga handlers"
|
||||
meta: flush_handlers
|
||||
|
||||
- name: "Create Taiga admin user (idempotent)"
|
||||
command: >
|
||||
docker compose
|
||||
-f {{ TAIGA_DOCKER_COMPOSE_PATH }}
|
||||
-f {{ TAIGA_DOCKER_COMPOSE_INIT_PATH }}
|
||||
run --rm taiga-manage
|
||||
createsuperuser --noinput
|
||||
--username {{ TAIGA_SUPERUSER_NAME }}
|
||||
--email {{ TAIGA_SUPERUSER_EMAIL }}
|
||||
environment:
|
||||
DJANGO_SUPERUSER_PASSWORD: "{{ TAIGA_SUPERUSER_PASSWORD }}"
|
||||
args:
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
register: taiga_create_admin
|
||||
changed_when: taiga_create_admin.rc == 0
|
||||
failed_when: >
|
||||
taiga_create_admin.rc != 0 and
|
||||
('already taken' not in (taiga_create_admin.stdout + taiga_create_admin.stderr) | lower) and
|
||||
('already exists' not in (taiga_create_admin.stdout + taiga_create_admin.stderr) | lower) and
|
||||
('integrityerror' not in (taiga_create_admin.stdout + taiga_create_admin.stderr) | lower)
|
||||
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
||||
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
|
||||
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
||||
- name: "Include Taiga administrator routines"
|
||||
include_tasks: 01_administrator.yml
|
Reference in New Issue
Block a user