Skip to content

Instantly share code, notes, and snippets.

@dnd
Created January 7, 2015 16:46
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 dnd/3329901fb90feb8dddd4 to your computer and use it in GitHub Desktop.
Save dnd/3329901fb90feb8dddd4 to your computer and use it in GitHub Desktop.
_grains/environment.py
#!/usr/bin/env python
import salt.log
import salt.utils
def environment():
fqdn = salt.utils.network.get_fqhostname()
host = fqdn.partition('.')[0]
grains = {}
environment = __salt__['envutil.infer_env_from_name'](host)
grains['environment'] = environment
return grains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment