Created
October 4, 2012 17:53
-
-
Save zippyz/3835263 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
__description__ = "Salt Grain for gathering an environment variable" | |
import os,sys,logging | |
#logging.basicConfig(level=logging.DEBUG) | |
from pprint import pprint | |
def _file_get_contents(filename): | |
if os.path.exists(filename): | |
content = {} | |
with open(filename, "r") as _file: | |
for line in _file: | |
(key, val) = line.split() | |
content[str(key)] = val | |
_file.close() | |
return content | |
def return_grains(): | |
grains = {} | |
filename = "/environment" | |
# grains['custom_env'] = _file_get_contents(filename) | |
grains = _file_get_contents(filename) | |
if 'env_grain': | |
pprint(grains) | |
# print(type(grains)) | |
return grains | |
return_grains() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment