Skip to content

Commit 4348df8

Browse files
committed
docs(tofs): use {%- for all Jinja statements
1 parent 5105d29 commit 4348df8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

TOFS_pattern.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ file_roots:
8181

8282
```
8383
## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/map.jinja
84-
{% set ntp = salt['grains.filter_by']({
84+
{%- set ntp = salt['grains.filter_by']({
8585
'default': {
8686
'pkg': 'ntp',
8787
'service': 'ntp',
@@ -94,7 +94,7 @@ In `init.sls` we have the minimal states required to have NTP configured. In man
9494

9595
```
9696
## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/init.sls
97-
{% from 'ntp/map.jinja' import ntp with context %}
97+
{%- from 'ntp/map.jinja' import ntp with context %}
9898
9999
Install NTP:
100100
pkg.installed:
@@ -115,7 +115,7 @@ In `conf.sls` we have the configuration states. In most cases, that is just mana
115115
include:
116116
- ntp
117117
118-
{% from 'ntp/map.jinja' import ntp with context %}
118+
{%- from 'ntp/map.jinja' import ntp with context %}
119119
120120
Configure NTP:
121121
file.managed:
@@ -134,8 +134,8 @@ Under `files/default`, there is a structure that mimics the one in the minion in
134134
## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/files/default/etc/ntp.conf.jinja
135135
# Managed by saltstack
136136
# Edit pillars or override this template in saltstack if you need customization
137-
{% set settings = salt['pillar.get']('ntp', {}) %}
138-
{% set default_servers = ['0.ubuntu.pool.ntp.org',
137+
{%- set settings = salt['pillar.get']('ntp', {}) %}
138+
{%- set default_servers = ['0.ubuntu.pool.ntp.org',
139139
'1.ubuntu.pool.ntp.org',
140140
'2.ubuntu.pool.ntp.org',
141141
'3.ubuntu.pool.ntp.org'] %}
@@ -146,9 +146,9 @@ filegen loopstats file loopstats type day enable
146146
filegen peerstats file peerstats type day enable
147147
filegen clockstats file clockstats type day enable
148148
149-
{% for server in settings.get('servers', default_servers) %}
149+
{%- for server in settings.get('servers', default_servers) %}
150150
server {{ server }}
151-
{% endfor %}
151+
{%- endfor %}
152152
153153
restrict -4 default kod notrap nomodify nopeer noquery
154154
restrict -6 default kod notrap nomodify nopeer noquery
@@ -201,9 +201,9 @@ If the customization based on pillar data is not enough, we can override the tem
201201
# Some bizarre configurations here
202202
# ...
203203
204-
{% for server in settings.get('servers', default_servers) %}
204+
{%- for server in settings.get('servers', default_servers) %}
205205
server {{ server }}
206-
{% endfor %}
206+
{%- endfor %}
207207
```
208208

209209
This way we are locally **overriding the template files** offered by the formula in order to make a more complex adaptation. Of course, this could be applied as well to any of the files, including the state files.
@@ -237,7 +237,7 @@ To make this work we need a `conf.sls` state file that takes a list of possible
237237
include:
238238
- ntp
239239
240-
{% from 'ntp/map.jinja' import ntp with context %}
240+
{%- from 'ntp/map.jinja' import ntp with context %}
241241
242242
Configure NTP:
243243
file.managed:
@@ -270,7 +270,7 @@ To make this work we could write a specially crafted `conf.sls`.
270270
include:
271271
- ntp
272272
273-
{% from 'ntp/map.jinja' import ntp with context %}
273+
{%- from 'ntp/map.jinja' import ntp with context %}
274274
275275
Configure NTP:
276276
file.managed:
@@ -293,8 +293,8 @@ We can simplify the `conf.sls` with the new `files_switch` macro to use in the `
293293
include:
294294
- ntp
295295
296-
{% from 'ntp/map.jinja' import ntp with context %}
297-
{% from 'ntp/macros.jinja' import files_switch %}
296+
{%- from 'ntp/map.jinja' import ntp with context %}
297+
{%- from 'ntp/macros.jinja' import files_switch %}
298298
299299
Configure NTP:
300300
file.managed:

0 commit comments

Comments
 (0)