Merge pull request #2 from puneetk/master
Make the formula fully pillar driven/customizable
This commit is contained in:
commit
411d98b6e0
|
@ -10,7 +10,8 @@ Here's a small pillar data sample::
|
|||
sysctl:
|
||||
lookup:
|
||||
pkg: procps-ng
|
||||
config_location: /etc/sysctl.d
|
||||
config:
|
||||
location: /etc/sysctl.d
|
||||
params:
|
||||
vm.swappines:
|
||||
value: 20
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
sysctl:
|
||||
lookup:
|
||||
pkg: procps-ng
|
||||
config:
|
||||
location: '/etc/sysctl.d'
|
||||
params:
|
||||
fs.file-max:
|
||||
-
|
||||
name: fs.file-max
|
||||
value: 100000
|
||||
config: fs.conf
|
||||
vm.swappiness:
|
||||
-
|
||||
name: vm.swappiness
|
||||
value: 20
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
sysctl:
|
||||
pkg: procps-ng
|
||||
config:
|
||||
location: '/etc/sysctl.d'
|
||||
params:
|
||||
-
|
||||
name: fs.file-max
|
||||
value: 100000
|
||||
config: fs.conf
|
||||
-
|
||||
name: vm.swappiness
|
||||
value: 20
|
|
@ -1,23 +1,6 @@
|
|||
{% 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 -%}
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- sysctl.package
|
||||
- sysctl.param
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
{% set sysctl = salt['grains.filter_by']({
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=jinja
|
||||
|
||||
{## Start with defaults from defaults.sls ##}
|
||||
{% import_yaml 'sysctl/defaults.yml' as default_settings %}
|
||||
|
||||
{## setup variable using grains['os_family'] based logic ##}
|
||||
{% set os_family_map = salt['grains.filter_by']({
|
||||
'Arch': {
|
||||
'pkg' : 'procps-ng',
|
||||
'config_location' : '/etc/sysctl.d',
|
||||
},
|
||||
}, merge=salt['pillar.get']('sysctl:lookup')) %}
|
||||
"config": {
|
||||
"location": '/etc/sysctl.d',
|
||||
}
|
||||
}
|
||||
}, grain="os_family")
|
||||
%}
|
||||
{## Merge the flavor_map to the default settings ##}
|
||||
{% do default_settings.sysctl.update(os_family_map) %}
|
||||
|
||||
{## Merge in sysctl:lookup pillar ##}
|
||||
{% set sysctl_settings = salt['pillar.get'](
|
||||
'sysctl:lookup',
|
||||
default=default_settings.sysctl,
|
||||
merge=True
|
||||
)
|
||||
%}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{## import settings from map.jinja ##}
|
||||
{% from "sysctl/map.jinja" import sysctl_settings with context %}
|
||||
|
||||
sysctl-pkg:
|
||||
pkg.installed:
|
||||
- name: {{ sysctl_settings.pkg }}
|
||||
- failhard: True
|
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{## import settings from map.jinja ##}
|
||||
{% from "sysctl/map.jinja" import sysctl_settings with context %}
|
||||
|
||||
{% for param in sysctl_settings.get('params', {}) %}
|
||||
{% if param is mapping %}
|
||||
sysctl-present-{{ param.name }}:
|
||||
sysctl.present:
|
||||
- name: {{ param.name }}
|
||||
- value: {{ param.version }}
|
||||
{% if param.config is defined %}
|
||||
- config: {{ sysctl_settings.config.location }}/{{ param.config }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
Loading…
Reference in New Issue