diff --git a/states/systemd/defaults.yaml b/states/systemd/defaults.yaml index fb51b7c..bba4f0c 100644 --- a/states/systemd/defaults.yaml +++ b/states/systemd/defaults.yaml @@ -10,3 +10,6 @@ systemd: networkd: Network: SpeedMeter: "yes" + presets: + ssh: + - enable ssh diff --git a/states/systemd/init.sls b/states/systemd/init.sls index 213cca9..49d7dc9 100644 --- a/states/systemd/init.sls +++ b/states/systemd/init.sls @@ -22,3 +22,22 @@ systemd-service-{{ module }}: - watch: - file: systemd-configfile-{{ module }} {% endfor %} + +system-preset-main-dir: + file.directory: + - name: {{ systemd.confdir }}/system-preset + +{% for name, preset in systemd.presets.items() %} +systemd-preset-{{ name }}: + file.managed: + - name: {{ systemd.confdir }}/system-preset/00-{{ name }}.preset + - source: salt://systemd/templates/preset.j2 + - template: jinja + - user: root + - group: root + - mode: 0644 + - context: + preset: {{ preset }} + - require: + - file: {{ systemd.confdir }}/system-preset +{% endfor %} diff --git a/states/systemd/templates/system-preset.j2 b/states/systemd/templates/system-preset.j2 new file mode 100644 index 0000000..150bcd4 --- /dev/null +++ b/states/systemd/templates/system-preset.j2 @@ -0,0 +1,4 @@ +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} +{% for rule in preset -%} +{{ rule }} +{%- endfor %} diff --git a/states/systemd/templates/systemd_custom.conf.j2 b/states/systemd/templates/systemd_custom.conf.j2 index c1f0e7d..6d6463a 100644 --- a/states/systemd/templates/systemd_custom.conf.j2 +++ b/states/systemd/templates/systemd_custom.conf.j2 @@ -1,3 +1,4 @@ +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} {% for module, setting in settings.items() -%} [{{ module }}] {%- for key, value in setting.items() %}