Skip to content

Instantly share code, notes, and snippets.

@cmclaughlin
Last active December 20, 2017 21:52
Show Gist options
  • Save cmclaughlin/446801c4616557adbc746ae8b0cce3b3 to your computer and use it in GitHub Desktop.
Save cmclaughlin/446801c4616557adbc746ae8b0cce3b3 to your computer and use it in GitHub Desktop.
#!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