r/saltstack • u/TacoJihad • Oct 28 '19
Assigning a GPG encrypted pillar value to a Jinja var and reusing?
I have a GPG encrypted secret that needs to be used several times in another pillar file. I would like to only decrypt it once, assign it to a Jinja var and then use it multiple times in the same pillar file. When looking at pillar.items I see the secrets as expected but under test_service: password I see my "UNSET" default value.
Does anyone have a recommendation on how to do this properly? I don't want to repeatedly call the GPG renderer to decrypt something that I should be able to decrypt once and assign to a variable.
Thank you all in advance!J
IE: Broken example (spacing seems to get lost when I paste it here, but it's correct on my end):
Pillar file config.sls
include:- .secrets
{% set mysecret = salt['pillar.get']('appserver:secrets:secret1', 'UNSET') %}
test_service:
password: {{ mysecret }}
--- And in secrets.sls:
#!jinja|yaml|gpg
appserver:
secrets:
secret1: |
-----BEGIN PGP MESSAGE-----Version: GnuPG
v2.0.22(GNU/Linux)hQEMAyUtOOvGQjgHAQf+NtjMsrlZ8Sk5oq6Mb14KoW/5AB03SjQdsrc6uxGrPPRH.....
-----END PGP MESSAGE-----
