Last active
December 20, 2017 21:52
-
-
Save cmclaughlin/446801c4616557adbc746ae8b0cce3b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!py | |
# Pin the minion to a specific saltenv/pillarenv | |
def run(): | |
config = {} | |
env_map = {} | |
for env_key in ('saltenv', 'pillarenv'): | |
if env_key in __grains__.keys(): | |
# saltenv/pillarenv grains are set | |
# pin to those environments | |
env_map[env_key] = __grains__[env_key] | |
else: | |
# saltenv/pillarenv grains are not set | |
# pin to base/prod environment | |
env_map[env_key] = 'base' | |
config['/etc/salt/minion.d/_env.conf'] = { | |
'file.managed': [ | |
{'source': 'salt://shopstyle-salt/files/_env.conf'}, | |
{'template': 'jinja'}, | |
{'mode': 600}, | |
{'context': {'saltenv': env_map['saltenv'], | |
'pillarenv': env_map['pillarenv']}} | |
] | |
} | |
return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment