Skip to content

Instantly share code, notes, and snippets.

@jalons
Created May 18, 2015 18:29
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 jalons/c610b81f06ef7673004f to your computer and use it in GitHub Desktop.
Save jalons/c610b81f06ef7673004f to your computer and use it in GitHub Desktop.
custom grain __salt__
def __virtual__():
return "my_grain"
def my_grain():
grains = {}
test = __salt__['cmd.run']("awk '{/test/; print $2}' /tmp/foo.txt")
grains['my_grain'] = test
return grains
CRITICAL] Failed to load grains defined in grain file my_grain.my_grain in function <function my_grain at 0x2b70578>, error:
Traceback (most recent call last):
File "/home/jeremy.alons/linux/venv/lib/python2.7/site-packages/salt/loader.py", line 911, in gen_grains
ret = fun()
File "/home/jeremy.alons/linux/salt/var/cache/salt/minion/extmods/grains/foograin.py", line 6, in my_grain
test = __salt__['cmd.run']("awk '{/test/; print $2}' /tmp/foo.txt")
KeyError: 'cmd.run'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment