Can't access grains in salt state when declared in included config
By default a salt minion includes its config from files in /minion.d. However, if you elect to store grains in these files they will not be available to salt states. The grain appears when calling grains.item but raises an error when accessed by a salt state.
Data failed to compile:
----------
Rendering SLS failed, render error:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/utils/templates.py", line 99, in jinja
data = template.render(**passthrough)
File "/usr/lib/python2.6/site-packages/jinja2/environment.py", line 891, in render
return self.environment.handle_exception(exc_info, True)
File "/var/cache/salt/files/base/users/users.sls", line 18, in top-level template code
grains['foo']
UndefinedError: 'dict object' has no attribute 'foo'
Due to this it is also not possible to target custom grains in top.sls since the salt state will think they're not set.
What do your config files look like? I imagine that the grains are being overwritten by multiple calls
They look like the default plus a grains.conf in minion.d.
Ok, we will look into reproducing this, 0.10.4 I assume?
10.3
upgrade to 0.10.4 . or un-comment line in /etc/salt/minion (if still using 0.10.3)
default_include: minion.d/*.conf
see if that works. there was a bug in 0.10.3, that was fixed in 0.10.4
Uncommenting the default_include line fixed it on 10.3. I can't upgrade to 10.4 yet because my mirror doesn't have it.
Sounds good, I will close this out then, thanks @mlister2006 !