ansible/roles/base: Set XDG_RUNTIME_DIR as required by systemd
authornicoo <nicoo@realraum.at>
Tue, 14 Nov 2017 23:51:17 +0000 (00:51 +0100)
committernicoo <nicoo@realraum.at>
Tue, 14 Nov 2017 23:51:17 +0000 (00:51 +0100)
ansible/roles/base/files/xdg_runtime_dir.sh [new file with mode: 0644]
ansible/roles/base/tasks/main.yaml

diff --git a/ansible/roles/base/files/xdg_runtime_dir.sh b/ansible/roles/base/files/xdg_runtime_dir.sh
new file mode 100644 (file)
index 0000000..d2428b1
--- /dev/null
@@ -0,0 +1,4 @@
+# Set XDG_RUNTIME_DIR correctly
+if [ "$UID" -ne 0 ] && [ -z "${XDG_RUNTIME_DIR}" ]; then
+    export XDG_RUNTIME_DIR="/run/user/$(id -u)"
+fi
index c0d4ffd..7f60b4e 100644 (file)
     - zsh
     - python-apt
 
-- name: install systemd specific packages
-  apt: name={{ item }} state=present
-  with_items:
-    - dbus
-    - libpam-systemd
+- block:
+    - name: install systemd specific packages
+      apt: name={{ item }} state=present
+      with_items:
+        - dbus
+        - libpam-systemd
+
+    - name: set systemd-related environment variables
+      copy: src=xdg_runtime_dir.sh dest=/etc/profile.d/xdg_runtime_dir.sh mode=0644
+
   when: ansible_service_mgr == "systemd"
 
 - name: install zshrc