add sysctl state

This commit is contained in:
Paul 2025-02-18 18:39:08 +01:00
parent 535428d302
commit adc327c92e
5 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
sysctl:
config: {}
10-kube:
net.ipv4.ip_forward: 1
net.ipv6.conf.all.forwarding: 1
net.ipv6.conf.all.disable_ipv6: 0
net.core.bpf_jit_enable: 1

17
states/sysctl/init.sls Normal file
View File

@ -0,0 +1,17 @@
{%- from "sysctl/map.jinja" import sysctl with context %}
{%- for file,sysctls in sysctl.config.items() %}
sysctl-values:
file.keyvalue:
- name: /etc/sysctl.d/{{ file }}.conf
- key_values:
{%- for key,value in sysctls.items() %}
{{ key }}: {{ value }}
{%- endfor %}
- separator: '='
- uncomment: '# '
- key_ignore_case: True
- append_if_not_found: True
sysctl-apply:
cmd.run:
- name: "sysctl --system"

View File

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

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

@ -0,0 +1,14 @@
{%- import_yaml "sysctl/defaults.yaml" as default_settings -%}
{%- import_yaml "sysctl/kernelmap.yaml" as kernelmap -%}
{%- import_yaml "sysctl/osarchmap.yaml" as osarchmap -%}
{%- set defaults = salt['grains.filter_by'](default_settings,
default='sysctl',
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
)
)
-%}
{%- set sysctl = salt['pillar.get']('sysctl', 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"