Browse Source

fix: create parent folder for drop-in config files

Fabian Peter Hammerle 2 years ago
parent
commit
c45806bb99
1 changed files with 8 additions and 1 deletions
  1. 8 1
      tasks/main.yml

+ 8 - 1
tasks/main.yml

@@ -7,12 +7,19 @@
     mode: a=r
   register: _config_file
   when: systemd_unit_config is defined
+- name: 'create parent folder for drop-in config files of systemd unit {{ systemd_unit_name }}'
+  file:
+    path: '/etc/systemd/system/{{ systemd_unit_name }}.d'
+    state: directory
+    mode: u=rwx,go=rx
+  register: _dropin_config_dir
+  when: systemd_unit_dropin_config is defined
 - name: 'configure systemd unit {{ systemd_unit_name }} via drop-in config'
   copy:
     # > Along with a unit file foo.service, a "drop-in" directory foo.service.d/ may
     # > exist. All files with the suffix ".conf" from this directory will be parsed
     # > after the unit file itself is parsed.
-    dest: '/etc/systemd/system/{{ systemd_unit_name }}.d/override.conf'
+    dest: '{{ _dropin_config_dir.path }}/override.conf'
     content: |
       # ansible managed
       {{ systemd_unit_dropin_config }}