summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2025-04-04 02:21:01 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2025-04-04 02:21:01 +0200
commit7675dc593326936276cea39f347342bcad8fd96c (patch)
tree542174c803b03b79483a8b52a98b13f02af3d95e
parent23f6b16a3cf30cc6b87ed62496e180be5f125177 (diff)
downloadansible-ship-7675dc593326936276cea39f347342bcad8fd96c.tar.gz
ansible-ship-7675dc593326936276cea39f347342bcad8fd96c.zip
setup: generate & enable systemd units
Restarts container automatically on restart. Account lingering ensures that a systemd user management is started on device bootup.
-rw-r--r--setup.yml30
1 files changed, 28 insertions, 2 deletions
diff --git a/setup.yml b/setup.yml
index 6d3e03e..5fe4922 100644
--- a/setup.yml
+++ b/setup.yml
@@ -27,8 +27,9 @@
# -- LINGER ----------------------------------------------------------------
- # Enable lingering for user, such that processes are not killed if
- # there is no login session.
+ # Enable lingering for user. A user manager is spawned for the user at boot
+ # and kept around after logouts. This allows users who are not logged in to
+ # run long-running services.
- name: enable-linger
become: true
command: loginctl enable-linger {{ user }}
@@ -117,3 +118,28 @@
- "/etc/localtime:/etc/localtime:ro"
device:
- "/dev/ttyUSB0:/dev/ttyUSB0"
+
+ # -- USER SYSTEMD UNITS ----------------------------------------------------
+
+ - name: generate-user-systemd-units
+ containers.podman.podman_generate_systemd:
+ name: "{{ item }}"
+ dest: ~/.config/systemd/user/
+ restart_policy: on-failure
+ restart_sec: 10
+ loop:
+ - ftp
+ - mosquitto
+ - homeassistant
+
+ - name: enable-user-systemd-units
+ ansible.builtin.systemd:
+ name: "container-{{ item }}"
+ scope: user
+ daemon_reload: true
+ #state: started
+ enabled: true
+ loop:
+ - ftp
+ - mosquitto
+ - homeassistant