Browse Source

add support for `systemd_unit_scope: user`

Fabian Peter Hammerle 10 months ago
parent
commit
66a5828b2c
2 changed files with 6 additions and 2 deletions
  1. 1 1
      README.md
  2. 5 1
      tasks/main.yml

+ 1 - 1
README.md

@@ -9,7 +9,7 @@ systemd_unit_name: some.service
 ## Optional Variables
 
 ```yaml
-systemd_unit_scope: global # all users (default: system)
+systemd_unit_scope: global # "system" (default), "global" or "user"
 systemd_unit_config: |
   [Unit]
   Description=…

+ 5 - 1
tasks/main.yml

@@ -6,7 +6,11 @@
       {{ systemd_unit_config }}
     mode: a=r
   vars: &copy_config_file_vars
-    _config_dir_path: '/etc/systemd/{{ "user" if (systemd_unit_scope == "global") else systemd_unit_scope }}'
+    _config_dir_path: >-
+      {{ '~/.config/systemd/user' if systemd_unit_scope == 'user'
+         else '/etc/systemd/' + (
+           "user" if systemd_unit_scope == "global" else systemd_unit_scope
+         ) }}
   register: _config_file
   when: systemd_unit_config is defined
 - name: 'create parent folder for drop-in config files of systemd unit {{ systemd_unit_name }}'