11{% if pillar[' promtail' ] is defined and pillar[' promtail' ] is not none %}
2-
3- {% if " acme_domain" in pillar[" promtail" ] %}
4-
5- {% from " acme/macros.jinja" import verify_and_issue % }
6-
7- {% set acme = pillar[" acme" ].keys() | first % }
8-
2+ {%- if " acme_domain" in pillar[" promtail" ] %}
3+ {%- from " acme/macros.jinja" import verify_and_issue % }
4+ {%- set acme = pillar[" acme" ].keys() | first % }
95 {{ verify_and_issue(acme, " promtail" , pillar[" promtail" ][" acme_domain" ]) }}
10-
11- {% endif % }
6+ {%- endif % }
127
13- {% if pillar[" promtail" ][" scrape_configs" ] is defined and pillar[" promtail" ][" config" ] is defined % }
8+ {%- if pillar[" promtail" ][" scrape_configs" ] is defined and pillar[" promtail" ][" config" ] is defined % }
149
1510pillar must contain either " promtail.config" or " promtail.scrape_configs" block:
1611 test.fail_without_changes:
1712 - name: Pillar must contain either " promtail.config" or " promtail.scrape_configs" block.
1813
19- {% else % }
14+ {%- else % }
2015
2116promtail_data_dirs:
2217 file .directory:
@@ -37,15 +32,15 @@ promtail_data_dirs:
3732 own key and they all end up here.
3833 If config_scrape_parts is empty or absent, a warning is issued and Promtail will not be deployed.
3934 ================================================================ # }
40- {% set config_deployed = { ' is_ready' : false } % }
41- {% if " config_global_part" in pillar[" promtail" ] % }
42- {% set scrape_fragments = [] % }
43- {% if " config_scrape_parts" in pillar[" promtail" ] % }
44- {% for part_name in pillar[" promtail" ][" config_scrape_parts" ].keys() | sort % }
45- {% set _ = scrape_fragments.append(pillar[" promtail" ][" config_scrape_parts" ][part_name]) % }
46- {% endfor % }
47- {% endif % }
48- {% if scrape_fragments | length == 0 % }
35+ {%- set config_deployed = { ' is_ready' : false } % }
36+ {%- if " config_global_part" in pillar[" promtail" ] % }
37+ {%- set scrape_fragments = [] % }
38+ {%- if " config_scrape_parts" in pillar[" promtail" ] % }
39+ {%- for part_name in pillar[" promtail" ][" config_scrape_parts" ].keys() | sort % }
40+ {%- set _ = scrape_fragments.append(pillar[" promtail" ][" config_scrape_parts" ][part_name]) % }
41+ {%- endfor % }
42+ {%- endif % }
43+ {%- if scrape_fragments | length == 0 % }
4944
5045promtail_no_scrape_jobs:
5146 test.configurable_test_state:
@@ -56,9 +51,9 @@ promtail_no_scrape_jobs:
5651 promtail: config_global_part is set but no config_scrape_parts jobs are attached.
5752 Promtail config will NOT be deployed until at least one job pillar is connected via top_sls.
5853
59- {% else % }
60- {% set merged_scrape_text = scrape_fragments | join(' \n ' ) % }
61- {% set _ = config_deployed.update({' is_ready' : true}) % }
54+ {%- else % }
55+ {%- set merged_scrape_text = scrape_fragments | join(' \n ' ) % }
56+ {%- set _ = config_deployed.update({' is_ready' : true}) % }
6257
6358promtail_config:
6459 file .managed:
@@ -70,13 +65,13 @@ promtail_config:
7065 {{ pillar[' promtail' ][' config_global_part' ] | indent(8 ) }}
7166 scrape_configs:
7267 {{ merged_scrape_text | indent(8 ) }}
73- {% endif % }
68+ {%- endif % }
7469
7570 {# ================================================================
7671 LEGACY PATH 1 : promtail.scrape_configs (uses config.jinja template)
7772 ================================================================ # }
78- {% elif pillar[" promtail" ][" scrape_configs" ] is defined % }
79- {% set _ = config_deployed.update({' is_ready' : true}) % }
73+ {%- elif pillar[" promtail" ][" scrape_configs" ] is defined % }
74+ {%- set _ = config_deployed.update({' is_ready' : true}) % }
8075promtail_config:
8176 file .managed:
8277 - name: / opt/ promtail/ etc/ promtail.yaml
@@ -96,17 +91,17 @@ promtail_config:
9691 {# ================================================================
9792 LEGACY PATH 2 : promtail.config (full config verbatim)
9893 ================================================================ # }
99- {% elif pillar[" promtail" ][" config" ] is defined % }
100- {% set _ = config_deployed.update({' is_ready' : true}) % }
101- {% if pillar[" promtail" ][" loki" ] is defined or pillar[" promtail" ][" positions" ] is defined % }
94+ {%- elif pillar[" promtail" ][" config" ] is defined % }
95+ {%- set _ = config_deployed.update({' is_ready' : true}) % }
96+ {%- if pillar[" promtail" ][" loki" ] is defined or pillar[" promtail" ][" positions" ] is defined % }
10297when pillar contain " pillar.config" block:
10398 test.configurable_test_state:
10499 - name: nothing_done
105100 - changes: False
106101 - result: True
107102 - warnings: |
108103 When pillar contain " promtail.config" block, the " promtail.positions" , " promtail.loki" blocks are IGNORED
109- {% endif % }
104+ {%- endif % }
110105promtail_config:
111106 file .managed:
112107 - name: / opt/ promtail/ etc/ promtail.yaml
@@ -115,9 +110,9 @@ promtail_config:
115110 - group: 0
116111 - contents: |
117112 {{ pillar[' promtail' ][' config' ] | indent(8 ) }}
118- {% endif % }
113+ {%- endif % }
119114
120- {% if config_deployed[' is_ready' ] and ' docker' in pillar[' promtail' ] % }
115+ {%- if config_deployed[' is_ready' ] and ' docker' in pillar[' promtail' ] % }
121116promtail_image:
122117 cmd.run:
123118 - name: docker pull {{ pillar[' promtail' ][' docker' ][' image' ] }}
@@ -139,7 +134,7 @@ promtail_container:
139134 - watch:
140135 - / opt/ promtail/ etc/ promtail.yaml
141136 - command: - config.file=/ etc/ promtail/ promtail.yaml
142- {% elif config_deployed[' is_ready' ] % }
137+ {%- elif config_deployed[' is_ready' ] % }
143138
144139promtail_binary_1:
145140 archive.extracted:
@@ -191,7 +186,7 @@ promtail_systemd_4:
191186 - onchanges:
192187 - file : / etc/ systemd/ system/ promtail.service
193188 - file : / opt/ promtail/ etc/ promtail.yaml
194- {% endif % }
195- {% endif % }
189+ {%- endif % }
190+ {%- endif % }
196191{% endif % }
197192
0 commit comments