Rollen auf scope user|system generalisiert, gnmon_accounts-Rolle (gn-monitor 986), Testing-Inventory ghostnet-ki, Image-Transport per Tag-Ref. Fixes: Textfile-Collector HELP/TYPE je Familie (Multi-GPU), Restart-Handler je Scope, Loopback-Bindings VM/Loki (§7), scope- agnostische Playbook-Verifikationen. Server + Workstation idempotent. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
84 lines
2.9 KiB
YAML
84 lines
2.9 KiB
YAML
# GNMON-001 v2.0 section 5: Loki rootless quadlet.
|
|
- name: Validate Loki declarations
|
|
ansible.builtin.assert:
|
|
that:
|
|
- gnmon_loki_retention_days | int >= 1
|
|
fail_msg: Loki declarations are incomplete or ambiguous.
|
|
|
|
- name: Create Loki directories
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: directory
|
|
owner: "{{ item.owner | default(omit) }}"
|
|
group: "{{ item.group | default(omit) }}"
|
|
mode: "{{ item.mode | default('0755') }}"
|
|
loop:
|
|
- path: "{{ gnmon_loki_quadlet_dir }}"
|
|
- path: "{{ gnmon_loki_config_dir }}"
|
|
- path: "{{ gnmon_loki_data_dir }}"
|
|
owner: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
group: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
- path: "{{ gnmon_loki_data_dir }}/chunks"
|
|
owner: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
group: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
- path: "{{ gnmon_loki_data_dir }}/rules"
|
|
owner: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
group: "{{ gnmon_loki_run_user if gnmon_loki_scope == 'system' else omit }}"
|
|
|
|
- name: Install the Loki configuration
|
|
ansible.builtin.template:
|
|
src: loki-config.yaml.j2
|
|
dest: "{{ gnmon_loki_config_dir }}/loki-config.yaml"
|
|
mode: "0644"
|
|
notify: ["Restart Loki (user scope)", "Restart Loki (system scope)"]
|
|
|
|
- name: Install the Loki quadlet
|
|
ansible.builtin.template:
|
|
src: gnmon-loki.container.j2
|
|
dest: "{{ gnmon_loki_quadlet_dir }}/gnmon-loki.container"
|
|
mode: "0644"
|
|
notify: ["Restart Loki (user scope)", "Restart Loki (system scope)"]
|
|
|
|
- name: Reload the workload user manager (system scope)
|
|
ansible.builtin.command:
|
|
argv: [/usr/sbin/runuser, --user, "{{ gnmon_loki_run_user }}", --,
|
|
/usr/bin/env, "XDG_RUNTIME_DIR=/run/user/{{ gnmon_loki_run_uid }}",
|
|
/usr/bin/systemctl, --user, daemon-reload]
|
|
changed_when: false
|
|
when: gnmon_loki_scope == 'system'
|
|
|
|
- name: Enable and start the workload unit (system scope)
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ gnmon_loki_run_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME=/var/lib/gn-monitor"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ gnmon_loki_run_uid }}"
|
|
- /usr/bin/systemctl
|
|
- --user
|
|
- start
|
|
- gnmon-loki.service
|
|
changed_when: false
|
|
when: gnmon_loki_scope == 'system'
|
|
|
|
- name: Enable and start Loki (user scope)
|
|
ansible.builtin.systemd:
|
|
name: gnmon-loki.service
|
|
scope: user
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|
|
when: gnmon_loki_scope == 'user'
|
|
|
|
- name: Wait for the Loki readiness endpoint
|
|
ansible.builtin.uri:
|
|
url: "http://127.0.0.1:{{ gnmon_loki_port }}/ready"
|
|
status_code: 200
|
|
register: gnmon_loki_ready
|
|
retries: 30
|
|
delay: 2
|
|
until: gnmon_loki_ready.status == 200
|