瀏覽代碼

create parent folder for user unit files (to fix ansible error "Destination directory …/.config/systemd/user does not exist")

Fabian Peter Hammerle 7 月之前
父節點
當前提交
4cc1526840
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      tasks/main.yml

+ 8 - 1
tasks/main.yml

@@ -1,3 +1,10 @@
+---
+- name: create parent folder for unit files
+  ansible.builtin.file:
+    dest: ~/.config/systemd/user
+    state: directory
+  when: systemd_unit_scope == 'user'
+  register: _config_dir
 - name: 'configure systemd unit {{ systemd_unit_name }}'
   copy:
     dest: '{{ _config_dir_path }}/{{ systemd_unit_name }}'
@@ -7,7 +14,7 @@
     mode: a=r
   vars: &copy_config_file_vars
     _config_dir_path: >-
-      {{ '~/.config/systemd/user' if systemd_unit_scope == 'user'
+      {{ _config_dir.path if systemd_unit_scope == 'user'
          else '/etc/systemd/' + (
            "user" if systemd_unit_scope == "global" else systemd_unit_scope
          ) }}