Hi Dave,
Thanks for the quick reply. My python code isn't recognizing the __grains__ object...presumably I need a different include or predicate than what I am doing.
For example, this code should return the grain as a pillar (simplest example, I will of course be returning a subset as the pillar in the real example)
/srv/pillar/solarflare_interfaces.sls:
#!py
# include everything but the kitchen sink until I figure this out
import salt
import salt.client
import salt.utils
import salt.modules.cmdmod
def run():
eths = []
g_ipif = __grains__['ip_interfaces']
# add logic here once basic poc works
return g_ipif
if __name__ == "__main__":
p = run()
print(p)
result is:
_errors:
- Rendering SLS 'solarflare_interfaces' failed, render error:
- Traceback (most recent call last):
- File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 183, in py
- data = mod.run()
- File "/srv/pillar/solarflare_interfaces.sls", line 10, in run
- g_ipif = __grains__['ip_interfaces']
- NameError: global name '__grains__' is not defined
I'm sure this is down to my unfamiliarity of how salt is structured internally, but obvious choices like salt.__grains__ don't work either.
thanks,
Jean