GNMON-/GNAI-008 M4 Fix: Accountpruefung ohne getent-Faktencollision; Skript $2-Default

Das getent-Modul ueberschreibt seine Fakten je Aufruf und kollidiert mit
dem Loop; Ersatz durch getent-passwd-Kommandos mit gesammelten Ergebnissen.
switch-to-production ohne Fensterargument crashte unter set -u ($2);
nun mit Default. Verifikation: state-Datei aktiv, Timer enabled+active,
Recovery-Timer hat den Initialzustand selbst gesetzt.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-06 06:52:25 +01:00
parent 6664344b44
commit 6896120520
2 changed files with 23 additions and 9 deletions
@@ -24,24 +24,38 @@
- ai_environment_health_interval | int > 0
fail_msg: AI environment switch declarations are incomplete or ambiguous.
- name: Verify every environment account exists on the host
ansible.builtin.getent:
database: passwd
key: "{{ item.value.account }}"
- name: Read every environment account database entry
ansible.builtin.command:
argv:
- /usr/bin/getent
- passwd
- "{{ item.value.account }}"
register: ai_environment_account_entries
changed_when: false
failed_when: false
loop: "{{ ai_environment_definitions | dict2items }}"
loop_control:
label: "{{ item.value.account }}"
- name: Verify the account UID matches the declaration
- name: Verify the accounts exist with the declared UID
ansible.builtin.assert:
that:
- getent_passwd[item.value.account][1] | int == item.value.uid | int
- entry.stdout is defined
- entry.stdout | length > 0
- entry.stdout.split(':')[2] | int == item.value.uid | int
fail_msg: >-
UID mismatch for {{ item.value.account }}: declared {{ item.value.uid }},
host reports {{ getent_passwd[item.value.account][1] }}.
Account {{ item.value.account }} is missing or has UID
{{ entry.stdout.split(':')[2] | default('unset') }}
instead of the declared {{ item.value.uid }}.
loop: "{{ ai_environment_definitions | dict2items }}"
loop_control:
label: "{{ item.value.account }}"
loop_var: item
vars:
entry: >-
{{ ai_environment_account_entries.results
| selectattr('item.value.account', 'equalto', item.value.account)
| first }}
- name: Ensure the host configuration directory exists
ansible.builtin.file:
@@ -146,7 +146,7 @@ start_active_unit() {
switch_to() {
# $1 = target environment, $2 = window minutes (optional)
local target="$1" window_minutes="$2" other uid
local target="$1" window_minutes="${2:-}" other uid
local active unit refresh_window=""
case " $ENVIRONMENTS " in *" $target "*) ;; *)