Skip to content

Late-bound variable replacement #16

Answered by jgraichen
Oloremo asked this question in Q&A
Discussion options

You must be logged in to vote

Late-bound variable replacement by default only works in in tower top file. As this file is first passed through Jinja and Yaml before we can load any pillar data file there isn't any way to e.g. insert variables from the tower pillar with Jinja.

For regular pillar data files I do recommend to just place reused variables in a previously loaded file and use regular Jinja like this:

# tower.sls
base:
  - defaults.sls
  - pillar.sls
# defaults.sls
some_key:
  another_key: 1
# pillar.sls
special_key: {{ pillar.get('some_key:another_Key') }}

This would render into the following pillar result:

some_key:
  another_key: 1
special_key: 1

This is the recommended way for accessing pillar values that…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jgraichen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5 on April 02, 2021 11:36.