added systemd state

This commit is contained in:
Paul 2024-02-07 22:00:51 +01:00
parent f02e2563ca
commit 6e410e9123
6 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,12 @@
---
systemd:
confdir: /etc/systemd
config:
journald:
Journal:
Storage: auto
Compress: "yes"
SystemMaxUse: 500M
networkd:
Network:
SpeedMeter: "yes"

24
states/systemd/init.sls Normal file
View File

@ -0,0 +1,24 @@
---
{%- from "systemd/map.jinja" import systemd with context %}
{% for module,settings in systemd.config.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 %}

View File

@ -0,0 +1,3 @@
---
Linux:
os: "linux"

14
states/systemd/map.jinja Normal file
View File

@ -0,0 +1,14 @@
{%- import_yaml "systemd/defaults.yaml" as default_settings -%}
{%- import_yaml "systemd/kernelmap.yaml" as kernelmap %}
{%- import_yaml "systemd/osarchmap.yaml" as osarchmap %}
{%- set defaults = salt['grains.filter_by'](default_settings,
default='systemd',
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
)
)
-%}
{%- set systemd = salt['pillar.get']('systemd', default=defaults, merge=True) -%}

View File

@ -0,0 +1,24 @@
---
amd64:
arch: "amd64"
x86_64:
arch: "amd64"
386:
arch: "386"
arm64:
arch: "arm64"
aarch64:
arch: "arm64"
armv6l:
arch: "arm"
armv7l:
arch: "arm"
armhf:
arch: "arm"

View File

@ -0,0 +1,6 @@
{% for module, setting in settings.items() -%}
[{{ module }}]
{%- for key, value in setting.items() %}
{{ key }}={{ value }}
{%- endfor %}
{%- endfor %}