Skip to content

Instantly share code, notes, and snippets.

/exec.bash Secret

Created January 6, 2017 15:51
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 anonymous/77d93d99d9a32cc6f19d5263e486929e to your computer and use it in GitHub Desktop.
Save anonymous/77d93d99d9a32cc6f19d5263e486929e to your computer and use it in GitHub Desktop.
# on minion
root@minion# cat /etc/salt/minion
grains:
role: qa1
# ...
root@minion# salt-call grains.get role
local:
qa1
root@minion# salt-call state.apply
local:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'servers.qa' failed. Please see master log for details.
root@minion# salt-call saltutil.sync_grains
local:
root@minion# salt-call state.apply
local:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'servers.qa' failed. Please see master log for details.
# on master
root@master# salt -G 'role:qa1' grains.get role
i-010...:
qa1
2017-01-06 14:37:22,558 [salt.pillar ][CRITICAL][10803] Rendering SLS 'servers.qa' failed, render error:
Jinja error: unsupported operand type(s) for +: 'NoneType' and 'str'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 379, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 8, in top-level template code
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
; line 8
---
[...]
postgres:
host: {{ grains.get('role') + 'database.example.com' }} <======================
[...]
---
# pillar/servers/qa.sls
postgres:
host: {{ grains.get('role') + 'database.example.com' }}
# pillar/top.sls
base:
# ...
'role:qa*':
- match: grain
- servers.qa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment