-
-
Save jalons/c610b81f06ef7673004f to your computer and use it in GitHub Desktop.
custom grain __salt__
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
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 |
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
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