2016-12-13 22:37:53 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=jinja
|
|
|
|
{# Returns a generic block of values suitable for inclusion in most states #}
|
2014-05-22 20:38:27 +02:00
|
|
|
{% macro sls_block(dict, ind=4) %}
|
|
|
|
{% for key, value in dict.items() %}
|
|
|
|
{{ '-'|indent(ind, True) }} {{ key }}: {{ value|json() }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endmacro %}
|
|
|
|
|
2016-12-13 22:37:53 +01:00
|
|
|
{# Serializes dicts into sequenced data #}
|
2014-05-22 20:38:27 +02:00
|
|
|
{%- macro serialize(data) -%}
|
|
|
|
{%- if data is mapping -%}
|
|
|
|
{%- set ret = [] -%}
|
|
|
|
{%- for key, value in data.items() -%}
|
|
|
|
{%- set value = serialize(value)|load_json() -%}
|
|
|
|
{%- do ret.append({key: value}) -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- elif data is iterable and data is not string -%}
|
|
|
|
{%- set ret = [] -%}
|
|
|
|
{%- for value in data -%}
|
|
|
|
{%- set value = serialize(value)|load_json() -%}
|
|
|
|
{%- do ret.append(value) -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- else -%}
|
|
|
|
{% set ret = data %}
|
|
|
|
{%- endif -%}
|
|
|
|
|
|
|
|
{{ ret|json() }}
|
|
|
|
{%- endmacro -%}
|
2019-09-04 00:35:10 +02:00
|
|
|
|
|
|
|
{% macro file_requisites(states) %}
|
|
|
|
{%- for state in states %}
|
|
|
|
- file: {{ state }}
|
|
|
|
{%- endfor -%}
|
|
|
|
{% endmacro %}
|
2019-09-04 01:04:43 +02:00
|
|
|
|
|
|
|
{%- macro format_kwargs(kwarg) -%}
|
|
|
|
{%- filter indent(4) %}
|
|
|
|
{%- for k, v in kwarg|dictsort() %}
|
|
|
|
- {{ k }}: {{ v }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endfilter %}
|
|
|
|
{%- endmacro %}
|