aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/roles/systemd_requires_mount/tasks/main.yml
blob: cd4beb340b946960eabf257370303842a4b818fa (plain) (tree)





















                                                                              
- name: Set up systemd service dependency
  become: true
  block:
    - name: 'Create override directory: {{ service_name }}'
      ansible.builtin.file:
        path: '/etc/systemd/system/{{ service_name }}.service.d'
        state: directory

    - name: 'Set up override: {{ service_name }}'
      community.general.ini_file:
        dest: '/etc/systemd/system/{{ service_name }}.service.d/override.conf'
        section: Unit
        option: RequiresMountsFor
        value: '{{ mount_dir }}'
      register: overridden

    - name: 'Restart service: {{ service_name }}'
      ansible.builtin.systemd_service:
        daemon_reload: true
        name: '{{ service_name }}'
        state: restarted
      when: overridden.changed