sysctl-formula
This commit is contained in:
commit
40ad4fe142
|
@ -0,0 +1,27 @@
|
|||
sysctl
|
||||
======
|
||||
|
||||
This formula ensures that a sysctl parameter is present on the system
|
||||
from a pillar file.
|
||||
|
||||
|
||||
Here's a small pillar data sample::
|
||||
|
||||
sysclt:
|
||||
lookup:
|
||||
pkg: procps-ng
|
||||
config_location: /etc/sysctl.d
|
||||
params:
|
||||
vm.swappines:
|
||||
value: 20
|
||||
config: 10-swap.conf
|
||||
fs.file-max: 10000
|
||||
|
||||
|
||||
The state sysclt will ensure these are present on the system
|
||||
based on the sysctl module of salt.
|
||||
|
||||
if no config value is given the key value will be written based host system.
|
||||
on systemd systems this will be /etc/sysctl.d/99-salt.conf
|
||||
on sysv init systems it will be /etc/sysctl.conf
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
sysctl:
|
||||
lookup:
|
||||
pkg: procps-ng
|
||||
params:
|
||||
fs.file-max:
|
||||
value: 100000
|
||||
config: fs.conf
|
||||
vm.swappiness:
|
||||
value: 20
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{% from "sysctl/map.jinja" import sysctl with context %}
|
||||
|
||||
sysctl:
|
||||
pkg.installed:
|
||||
- name: {{ sysctl.pkg|json }}
|
||||
|
||||
{%- set config = pillar.get("sysctl", {} )%}
|
||||
{%- for name, item in config.get('params', {}).items() %}
|
||||
{%- if item == None -%}
|
||||
{% set item = {} -%}
|
||||
{%- endif -%}
|
||||
{%- set value = item.get('value', {}) %}
|
||||
{%- set config = item.get('config') %}
|
||||
|
||||
{{ name }}:
|
||||
sysctl.present:
|
||||
- name: {{ name }}
|
||||
- value: {{ value }}
|
||||
{%- if 'config' in item %}
|
||||
- config: {{ sysctl.config_location}}/{{ config }}
|
||||
{%- endif %}
|
||||
{%- endfor -%}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{% set sysctl = salt['grains.filter_by']({
|
||||
'Arch': {
|
||||
'pkg' : 'procps-ng',
|
||||
'config_location' : '/etc/sysctl.d',
|
||||
},
|
||||
}, merge=salt['pillar.get']('sysctl:lookup')) %}
|
Loading…
Reference in New Issue