From 9d3f30efe84b5b3718fa9951bc00278c0b350054 Mon Sep 17 00:00:00 2001 From: Wolodja Wentland Date: Thu, 16 Jun 2016 08:36:15 +0200 Subject: [PATCH] Check for presence of 'lookup' key Access to this key might have failed otherwise when the user specifies no pillar. --- sysctl/param.sls | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sysctl/param.sls b/sysctl/param.sls index ef4e286..0650766 100644 --- a/sysctl/param.sls +++ b/sysctl/param.sls @@ -23,32 +23,33 @@ sysctl-present-{{ param_name }}: {% endfor %} {% else %} {## Support for legacy pillar structure ##} - {%- if sysctl_settings.lookup.params2 is defined -%} - - {%- for param_name, param in sysctl_settings.lookup.get('params2', {}).items() -%} - {%- if param is mapping %} + {%- if sysctl_settings.lookup is defined %} + {% if sysctl_settings.lookup.params2 is defined -%} + {%- for param_name, param in sysctl_settings.lookup.get('params2', {}).items() -%} + {%- 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 %} - {% else %} + {% else %} - {%- for param in sysctl_settings.lookup.get('params', {}) -%} - {%- if param is mapping %} + {%- for param in sysctl_settings.lookup.get('params', {}) -%} + {%- 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 -%} - {% endif -%} - {% endfor %} + {% endfor %} + {% endif -%} {%- endif -%} {%- endif -%}