mirror of
https://github.com/saltstack-formulas/sysctl-formula.git
synced 2024-12-02 21:36:44 +01:00
cb2822f0f4
This commit allows users to specify sysctl parameters in an easier format than the one that was used before. It moves settings out of the 'lookup' pillar namespace in a backward compatible manner and is modelled after the old 'params2' approach. It also introduces a simplified scheme, in which parameters can be specified as key-value pairs, which makes for cleaner pillars if there is no need to specify a custom configuration file.
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
# -*- coding: utf-8 -*-
|
|
# vim: ft=sls
|
|
|
|
{## import settings from map.jinja ##}
|
|
{%- from "sysctl/map.jinja" import sysctl_settings with context -%}
|
|
|
|
{% if sysctl_settings.params is defined %}
|
|
{% for param_name, param in sysctl_settings.get('params').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 -%}
|
|
{% else %}
|
|
sysctl-present-{{ param_name }}:
|
|
sysctl.present:
|
|
- name: {{ param_name }}
|
|
- value: {{ param }}
|
|
{% endif %}
|
|
{% 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 %}
|
|
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.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 -%}
|
|
{% endfor %}
|
|
{%- endif -%}
|
|
{%- endif -%}
|