-
Notifications
You must be signed in to change notification settings - Fork 282
/
Copy pathmacros.jinja
34 lines (26 loc) · 912 Bytes
/
macros.jinja
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{%- from "postgres/map.jinja" import postgres with context -%}
{%- macro format_kwargs(kwarg) -%}
{%- filter indent(4) %}
{%- for k, v in kwarg|dictsort() %}
- {{ k }}: {{ v|yaml_dquote if v is string else v }}
{%- endfor %}
{%- endfilter %}
{%- endmacro %}
{%- macro format_state(name, state, kwarg) %}
{%- if 'name' not in kwarg %}
{%- do kwarg.update({'name': name}) %}
{%- endif %}
{%- if 'ensure' in kwarg %}
{%- set ensure = kwarg.pop('ensure') %}
{%- endif %}
{%- set user_available = not (state == 'postgres_schema' and grains.saltversioninfo < [2018, 3]) %}
{%- if 'user' not in kwarg and user_available %}
{%- do kwarg.update({'user': postgres.user}) %}
{%- endif -%}
{{ state }}-{{ name }}:
{{ state }}.{{ ensure|default('present') }}:
{{- format_kwargs(kwarg) }}
- onchanges:
- test: postgres-reload-modules
{%- endmacro %}
# vim: ft=sls