I'm not sure if I am thinking about this the right way, but here is my Problem:
I want to use the same Salt state and pillar configuration for production, development and test servers. The only difference should be:
- Which minions are used
- The values of Pillar keys, like passwords or usernames
I could go ahead and create different Pillar environments, but this would lead to separated sls files, which in turn means that the configurations could drift apart. Another aproach would be to use different git branches, one for each environment. But I imagine that this would lead to a lot of merge conficts.
If feel like the problem boils down to my pillar files having structure. For example, my pillar file for servers that have collectd
enabled:
#!yaml|gpg
collectd:
host:
ip: 1.2.3.4
port: 123
username: my_username
password: |
-----BEGIN PGP MESSAGE-----
...
-----END PGP MESSAGE-----
I would love to be able to use this file for all my environments just with different values, like so:
#!yaml|gpg
collectd:
host:
ip: $HOST_COLLECTD
port: 123
username: $USER_COLLECTD
password: $PASS_COLLECTD
Is something like this possible, or am I using Salt the wrong way?
Thanks!
EDIT, to add some information:
I am using git_pillar
to get the files directly from git. This allows me to have multiple environments without creating multiple directories, as each branch can be a environment. On solution I can think of is using templating to check the saltenv
. This feels a little hacky, but would do what I want for now:
#!yaml|gpg
collectd:
host:
ip: 1.2.3.4
port: 123
username: my_username
password: |
{% if saltenv == 'dev' %}
-----BEGIN PGP MESSAGE-----
...
-----END PGP MESSAGE-----
{% else %}
-----BEGIN PGP MESSAGE-----
...
-----END PGP MESSAGE-----
{% endif %}
I am still looking for better ways to solve my problem, though