Skip to content

Instantly share code, notes, and snippets.

@mikeywaites
Last active August 26, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeywaites/477a8acdf795e0188461 to your computer and use it in GitHub Desktop.
Save mikeywaites/477a8acdf795e0188461 to your computer and use it in GitHub Desktop.
"api_app": &api_app
...
"client_app": &client_app
...
[CRITICAL] Failed to load grains defined in grain file vizibl_config.vizibl_config in function <function vizibl_config at 0x7f09e1c07ed8>, error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 525, in grains
ret = fun()
File "/var/cache/salt/minion/extmods/grains/vizibl_config.py", line 7, in vizibl_config
NameError: global name '__salt__' is not defined
#!/usr/bin/env python
def vizibl_config():
grains = {}
node_id = __salt__['core.id_']()['id']
if node_id.startswith('prod'):
grains['VIZIBL_CONFIG'] = 'Prod'
elif node_id.startswith('stage'):
grains['VIZIBL_CONFIG'] = 'Stage'
elif node_id.startswith('sandbox'):
grains['VIZIBL_CONFIG'] = 'Sandbox'
elif node_id.startswith('qa'):
grains['VIZIBL_CONFIG'] = 'QA'
elif node_id.startswith('preprod'):
grains['VIZIBL_CONFIG'] = 'PreProd'
else:
grains['VIZIBL_CONFIG'] = 'Dev'
return grains
{% include "pyapps/apps.sls" %}
pyapps:
"foo":
<<: *api_app
"bar":
<<: *client_app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment