Skip to content

Instantly share code, notes, and snippets.

@chadhs
Created July 9, 2013 17:30
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 chadhs/0ef0a81ef3fcb8ea2622 to your computer and use it in GitHub Desktop.
Save chadhs/0ef0a81ef3fcb8ea2622 to your computer and use it in GitHub Desktop.
managing multiple versions of a config per role or nodegroup
FreeBSD-01:
Data failed to compile:
----------
Rendering SLS config failed, render error: Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/salt/utils/templates.py", line 63, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/local/lib/python2.7/site-packages/salt/utils/templates.py", line 116, in render_jinja_tmpl
output = jinja_env.from_string(tmplstr).render(**context)
File "/usr/local/lib/python2.7/site-packages/Jinja2-2.7-py2.7.egg/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python2.7/site-packages/Jinja2-2.7-py2.7.egg/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 8, in top-level template code
UndefinedError: 'dict object' has no attribute 'roles'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/salt/state.py", line 1877, in render_state
rendered_sls=mods
File "/usr/local/lib/python2.7/site-packages/salt/template.py", line 68, in compile_template
ret = render(input_data, env, sls, **render_kwargs)
File "/usr/local/lib/python2.7/site-packages/salt/renderers/jinja.py", line 41, in render
tmp_data.get('data', 'Unknown render error in jinja renderer')
SaltRenderError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/salt/utils/templates.py", line 63, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/local/lib/python2.7/site-packages/salt/utils/templates.py", line 116, in render_jinja_tmpl
output = jinja_env.from_string(tmplstr).render(**context)
File "/usr/local/lib/python2.7/site-packages/Jinja2-2.7-py2.7.egg/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python2.7/site-packages/Jinja2-2.7-py2.7.egg/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 8, in top-level template code
UndefinedError: 'dict object' has no attribute 'roles'
### configs
/usr/local/etc/pkg.conf:
file:
- managed
- source:
- salt://configs/{{ grains['roles'] }}-pkg.conf
- salt://configs/pkg.conf
- user: root
- group: wheel
- mode: 644
- require:
- pkg: pkg
pkg:
pkg:
- installed
@UtahDave
Copy link

UtahDave commented Jul 9, 2013

{{ salt['grains.get']('nodename', 'default value') }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment