The situation: We have multiple salt formulas with certain pillar-configured options that, in our environment, are identical. For example, they use the same URL for an upstream service. We would like to avoid duplicating these values in multiple pillar locations (we want a single point of truth), but we don't want to write the formulas in such a manner that they share pillar keys (orthoganality is good for the soul).
It seems to me that the right way to do this is to have one pillar file with the "shared" values and import them from there to the appropriate locations in the formula-specific pillar files. For example:
# pillar/shared.sls
upstream: https://example.com/youarehere
# pillar/formula1.sls
{%- from shared import upstream %}
formula1:
upstream_uri: {{ upstream }}
# pillar/formula2.sls
{%- from shared import upstream %}
formula2:
upstream_url: {{ upstream }}
# and so on...
Of course, that doesn't work as written. What's the correct way to do it?
Try this:
pillar/shared.sls
upstream: https://example.com/youarehere
pillar/formula1.sls
{% import_yaml "shared.sls" as defaults %}
formula1:
upstream_uri: {{ defaults.upstream }}
pillar/formula2.sls
{% import_yaml "shared.sls" as defaults %}
formula2:
upstream_url: {{ defaults.upstream }}