mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-03 03:38:15 +00:00
• Rename: 02_create-user.yml → 02_manage_user.yml; 03_create-token.yml → 03a_manage_user_token.yml + 03b_create_user_token.yml
• Only (re)run sys-svc-msmtp when no-reply token exists; set run_once_sys_svc_msmtp=true in 01_core
• Reset by setting run_once_sys_svc_msmtp=false after creating no-reply token; then include sys-svc-msmtp
• Harden when-guards (no '{{ }}' in when, safe .get lookups)
• Minor formatting and failed_when readability
Conversation: https://chatgpt.com/share/68ebd196-a264-800f-a215-3a89d0f96c79
26 lines
909 B
YAML
26 lines
909 B
YAML
|
|
- name: "Fetch existing API tokens via curl inside admin container"
|
|
command: >-
|
|
{{ docker_compose_command_exec }} -T admin \
|
|
curl -s -X GET {{ mailu_api_base_url }}/token \
|
|
-H "Authorization: Bearer {{ MAILU_API_TOKEN }}"
|
|
args:
|
|
chdir: "{{ MAILU_DOCKER_DIR }}"
|
|
register: mailu_tokens_cli
|
|
changed_when: false
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
|
|
|
- name: "Extract existing token info for '{{ mailu_user_key }};{{ mailu_user_name }}'"
|
|
set_fact:
|
|
mailu_user_existing_token: >-
|
|
{{ (
|
|
mailu_tokens_cli.stdout
|
|
| default('[]')
|
|
| from_json
|
|
| selectattr('comment','equalto', SOFTWARE_NAME)
|
|
| list
|
|
).0 | default(None) }}
|
|
|
|
- name: "Start Mailu token procedures for undefined tokens"
|
|
when: users[mailu_user_key].mailu_token is not defined
|
|
include_tasks: 03b_create_user_token.yml |