mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 01:30:25 +00:00

Regex: - `^` Line start - `#*\s*` Find line even if commented out - `(port)` 'port' -- capture as backreference `\1` - `\s*=\s*` Equals sign, whether or not surrounded by whitespace - `\d{4,5}` Existing port value, expected at 4/5 digits - `(.*)` Remainder (i.e. comment) -- capture as backreference `\2` - `$` Line end
32 lines
805 B
Django/Jinja
32 lines
805 B
Django/Jinja
{%- from "postgres/map.jinja" import postgres with context -%}
|
|
|
|
{%- macro format_kwargs(kwarg) -%}
|
|
|
|
{%- filter indent(4) %}
|
|
{%- for k, v in kwarg|dictsort() %}
|
|
- {{ k }}: {{ v }}
|
|
{%- endfor %}
|
|
{%- endfilter %}
|
|
|
|
{%- endmacro %}
|
|
|
|
{%- macro format_state(name, state, kwarg) %}
|
|
|
|
{%- do kwarg.update({'name': name}) %}
|
|
{%- if 'ensure' in kwarg %}
|
|
{%- set ensure = kwarg.pop('ensure') %}
|
|
{%- endif %}
|
|
{%- if 'user' not in kwarg and state != 'postgres_schema' %}
|
|
{%- do kwarg.update({'user': postgres.user}) %}
|
|
{%- endif -%}
|
|
|
|
{{ state }}-{{ name }}:
|
|
{{ state }}.{{ ensure|default('present') }}:
|
|
{{- format_kwargs(kwarg) }}
|
|
- db_port: {{ postgres.port|default(postgres.default_port) }}
|
|
- onchanges:
|
|
- test: postgres-reload-modules
|
|
|
|
{%- endmacro %}
|
|
|
|
# vim: ft=sls
|