feat: add systemd timer for zomboid container stats
Deploy systemd timer that writes zomboid container stats to zomboid-stats.json every 30 seconds for gregtime to read. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
5ac9b2fabe
commit
c2d117bd95
@@ -12,6 +12,84 @@
|
||||
- "{{ zomboid_path }}/server"
|
||||
- "{{ zomboid_path }}/data"
|
||||
- "{{ zomboid_path }}/scripts"
|
||||
- "{{ zomboid_path }}/logs"
|
||||
|
||||
- name: create podman bin directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ podman_home }}/bin"
|
||||
state: directory
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: deploy zomboid world reset script
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/world-reset.sh.j2
|
||||
dest: "{{ podman_home }}/bin/zomboid-world-reset.sh"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: deploy zomboid world reset path unit
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/zomboid-world-reset.path.j2
|
||||
dest: "{{ podman_home }}/.config/systemd/user/zomboid-world-reset.path"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0644'
|
||||
notify: reload zomboid systemd
|
||||
|
||||
- name: deploy zomboid world reset service unit
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/zomboid-world-reset.service.j2
|
||||
dest: "{{ podman_home }}/.config/systemd/user/zomboid-world-reset.service"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0644'
|
||||
notify: reload zomboid systemd
|
||||
|
||||
- name: deploy zomboid stats script
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/zomboid-stats.sh.j2
|
||||
dest: "{{ podman_home }}/bin/zomboid-stats.sh"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: deploy zomboid stats service unit
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/zomboid-stats.service.j2
|
||||
dest: "{{ podman_home }}/.config/systemd/user/zomboid-stats.service"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0644'
|
||||
notify: reload zomboid systemd
|
||||
|
||||
- name: deploy zomboid stats timer unit
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: zomboid/zomboid-stats.timer.j2
|
||||
dest: "{{ podman_home }}/.config/systemd/user/zomboid-stats.timer"
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
mode: '0644'
|
||||
notify: reload zomboid systemd
|
||||
|
||||
- name: enable zomboid stats timer
|
||||
become: true
|
||||
become_user: "{{ podman_user }}"
|
||||
ansible.builtin.systemd:
|
||||
name: zomboid-stats.timer
|
||||
scope: user
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
|
||||
- name: copy zomboid entrypoint script
|
||||
become: true
|
||||
@@ -190,9 +268,14 @@
|
||||
- zomboid_ini_stat.stat.exists
|
||||
tags: zomboid-conf
|
||||
|
||||
# World reset tasks REMOVED - too dangerous to have in automation
|
||||
# To reset the world manually:
|
||||
# 1. Stop the server: systemctl --user stop zomboid.service
|
||||
# 2. Delete saves: rm -rf /home/podman/.local/share/volumes/zomboid/data/Saves
|
||||
# 3. Delete db: rm -rf /home/podman/.local/share/volumes/zomboid/data/db
|
||||
# 4. Start the server: systemctl --user start zomboid.service
|
||||
# World reset is now triggered via Discord bot -> systemd path unit
|
||||
# See zomboid-world-reset.path and zomboid-world-reset.service
|
||||
- name: enable zomboid world reset path unit
|
||||
become: true
|
||||
become_user: "{{ podman_user }}"
|
||||
ansible.builtin.systemd:
|
||||
name: zomboid-world-reset.path
|
||||
scope: user
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=Write Zomboid container stats to file
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart={{ podman_home }}/bin/zomboid-stats.sh
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
# Write zomboid container stats to file for gregtime to read
|
||||
podman stats --no-stream --format json zomboid 2>/dev/null > {{ gregtime_path }}/data/zomboid-stats.json || true
|
||||
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Update Zomboid container stats every 30 seconds
|
||||
|
||||
[Timer]
|
||||
OnBootSec=30s
|
||||
OnUnitActiveSec=30s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user