0
0
mirror of https://github.com/saltstack-formulas/sysctl-formula.git synced 2024-11-28 01:18:18 +01:00

Merge pull request #22 from mgomersbach/move-to-os-yaml-files

Move data to YAML files and keep map.jinja a template
This commit is contained in:
Niels Abspoel 2018-10-17 19:40:52 +02:00 committed by GitHub
commit 7f24db81cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 32 deletions

View File

@ -1,45 +1,35 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
{## Start with defaults from defaults.sls ##}
{## Start with defaults from defaults.sls and osfamilymap.yml ##}
{% import_yaml 'sysctl/defaults.yml' as default_settings %}
{% import_yaml "sysctl/osfamilymap.yml" as os_family_map %}
{% set sysctl_lookup = salt['pillar.get']('sysctl:lookup', {}).copy() %}
{% if sysctl_lookup.params is defined %}
{% do sysctl_lookup.pop('params') %}
{% endif %}
{% if sysctl_lookup.params2 is defined %}
{% do sysctl_lookup.pop('params2') %}
{% endif %}
{## setup variable using grains['os_family'] based logic ##}
{% set os_family_map = salt['grains.filter_by']({
'Arch': {},
'RedHat': {
"config": {
"location": '/etc/sysctl.conf',
}
},
'Suse': {
"pkg": "procps",
},
'Debian': {
"pkg": "procps",
},
},
grain="os_family",
merge=sysctl_lookup)
{% set osfam = salt['grains.filter_by'](
os_family_map,
grain='os_family',
) or {}
%}
{## Merge the flavor_map to the default settings ##}
{% do default_settings.sysctl.update(os_family_map) %}
{% do salt['defaults.merge'](default_settings['sysctl'], osfam) %}
{% do salt['defaults.merge'](
default_settings['sysctl'],
salt['pillar.get']('sysctl:lookup',{}),
)
%}
{## Apply backwards compatiblility after merge ##}
{% if default_settings['sysctl']['params'] is defined %}
{% do default_settings['sysctl'].pop('params') %}
{% endif %}
{% if default_settings['sysctl']['params2'] is defined %}
{% do default_settings['sysctl'].pop('params2') %}
{% endif %}
{## Merge in sysctl pillar ##}
{% set sysctl_settings = salt['pillar.get'](
'sysctl',
default=default_settings.sysctl,
merge=True
default=default_settings['sysctl'],
merge=True,
)
%}

12
sysctl/osfamilymap.yml Normal file
View File

@ -0,0 +1,12 @@
RedHat:
config:
location: /etc/sysctl.conf
Suse:
pkg: procps
Debian:
pkg: procps
Gentoo:
pkg: sys-process/procps
FreeBSD:
config:
location: /etc/sysctl.conf