---
{%- from "systemd/map.jinja" import systemd with context %}
{% for module, settings in systemd.moduleconfig.items() %}
systemd-confdir-{{ module }}:
  file.directory:
    - name: {{ systemd.confdir }}/{{ module }}.conf.d/

systemd-configfile-{{ module }}:
  file.managed:
    - name: {{ systemd.confdir }}/{{ module }}.conf.d/custom.conf
    - source: salt://systemd/templates/systemd_custom.conf.j2
    - template: jinja
    - user: root
    - group: root
    - mode: 0644
    - context:
        settings: {{ settings }}

systemd-service-{{ module }}:
  service.running:
    - name: systemd-{{ module }}
    - watch:
      - file: systemd-configfile-{{ module }}
{% endfor %}