|
1 | 1 | {%- set control_params = ['module','enable'] %} |
2 | 2 | {%- set ind_increment = 4 %} |
3 | | -{%- macro _config(attr, ind=4, operator=' = ') -%} |
4 | | - {%- for n, v in attr.items() %} |
| 3 | +{%- macro _config(attr, ind=0, operator=' = ') -%} |
| 4 | + {#- We skip the module and enable params on first level #} |
| 5 | + {%- for n, v in attr.items() if n not in control_params or ind != 0 %} |
5 | 6 | {%- set operator=' ' if n.startswith('.include') else ' = ' %} |
6 | 7 | {%- if v is string %} |
| 8 | + {%- if v | regex_match('^([0-9]*[smhd])$') %} |
| 9 | +{{ n|indent(ind, True) }}{{ operator }}{{ v }}; |
| 10 | + {%- else %} |
7 | 11 | {{ n|indent(ind, True) }}{{ operator }}"{{ v }}"; |
| 12 | + {%- endif %} |
8 | 13 | {%- elif v is number %} |
9 | | -{{ n|indent(ind, True) }}{{ operator }}{{ v }}; |
10 | | - {%- elif v is mapping %} |
| 14 | +{{ n|indent(ind, True) }}{{ operator }}{{ v|json }}; |
| 15 | + {%- elif v is mapping %} |
11 | 16 | {{ n|indent(ind, True) }} { |
12 | | -{{ _config(v, ind+ind_increment) }} |
| 17 | +{{- _config(v, ind+ind_increment) }} |
13 | 18 | {{ '}'|indent(ind, True) }} |
14 | 19 | {%- elif v is iterable %} |
15 | 20 | {{ n|indent(ind, True) }}{{ operator }}["{{ v |join('", "') }}"]; |
|
19 | 24 | # This file managed by Salt, do not edit by hand!! |
20 | 25 | # Modify the salt pillar for rspamd, instead. |
21 | 26 | # |
22 | | -{%- for k, v in data.items() %} |
23 | | - {#- We skip the module and enable params #} |
24 | | - {%- if k not in control_params %} |
25 | | - {%- if v is string %} |
26 | | -{{ k }} = "{{ v }}"; |
27 | | - {%- elif v is number %} |
28 | | -{{ k }} = {{ v }}; |
29 | | - {%- elif v is mapping %} |
30 | | -{{ k }} { |
31 | | -{{ _config(v) }} |
32 | | -}; |
33 | | - {%- endif %} |
34 | | - {%- endif %} |
35 | | -{%- endfor %} |
| 27 | +{{ _config(data) }} |
0 commit comments