From 936c9908095bfa30aba9df3234855b5a9539927b Mon Sep 17 00:00:00 2001 From: Enver Date: Thu, 11 Feb 2016 15:16:46 +0100 Subject: [PATCH] Added support for dictionary params (params2) --- pillar.example | 7 +++++++ sysctl/param.sls | 28 +++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/pillar.example b/pillar.example index 21b0061..a311ee7 100644 --- a/pillar.example +++ b/pillar.example @@ -11,3 +11,10 @@ sysctl: - name: vm.swappiness value: 20 + # Setting params2 excludes all params values + params2: + fs.file-max: + value: 100000 + config: fs.conf + vm.swappiness: + value: 20 \ No newline at end of file diff --git a/sysctl/param.sls b/sysctl/param.sls index ae1bb99..f1ffa57 100644 --- a/sysctl/param.sls +++ b/sysctl/param.sls @@ -4,14 +4,32 @@ {## 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 %} +{% if sysctl_settings.get('params2', '') != '' %} + + {% for param_name, param in sysctl_settings.get('params2', {}).items() %} + {% if param is mapping %} +sysctl-present-{{ param_name }}: + sysctl.present: + - name: {{ param_name }} + - value: {{ param.value }} + {% if param.config is defined %} + - config: {{ sysctl_settings.config.location }}/{{ param.config }} + {% endif %} + {% endif %} + {% endfor %} + +{% else %} + + {% for param in sysctl_settings.get('params', {}) %} + {% if param is mapping %} sysctl-present-{{ param.name }}: sysctl.present: - name: {{ param.name }} - value: {{ param.value }} - {% if param.config is defined %} + {% if param.config is defined %} - config: {{ sysctl_settings.config.location }}/{{ param.config }} + {% endif %} {% endif %} - {% endif %} -{% endfor %} + {% endfor %} + +{% endif %}