- # -*- coding: utf-8 -*-
- # vim: ft=jinja
- {# Returns a generic block of values suitable for inclusion in most states #}
- {% macro sls_block(dict, ind=4) %}
- {% for key, value in dict.items() %}
- {{ '-'|indent(ind, True) }} {{ key }}: {{ value|json() }}
- {% endfor %}
- {% endmacro %}
-
- {# Serializes dicts into sequenced data #}
- {%- 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 -%}
-
- {% macro file_requisites(states) %}
- {%- for state in states %}
- - file: {{ state }}
- {%- endfor -%}
- {% endmacro %}
-
- {%- macro format_kwargs(kwarg) -%}
- {%- filter indent(4) %}
- {%- for k, v in kwarg|dictsort() %}
- - {{ k }}: {{ v }}
- {%- endfor %}
- {%- endfilter %}
- {%- endmacro %}
|