Closed Niyakiy closed 9 years ago
Protip: Use 3 ` (backticks) around code to keep markdown from trying to interpret parts of it.
I agree. Feel free to submit a PR to change it.
You should be able to just do:
{% if salt['pillar.get']('postgres:use_upstream_repo') %}
...
{% endif %}
Hello,
The lines mentioned in this ticket also cause errors in case no pillar data is set at all for "postgres". It should work out of the box with no additional configuration as stated in the documentation.
However, I get the following error:
[CRITICAL] Rendering SLS 'base:postgres' failed: Jinja error: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 286, in render_jinja_tmpl
output = template.render(**unicode_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 3, in top-level template code
TypeError: argument of type 'NoneType' is not iterable
; line 3
---
{% from "postgres/map.jinja" import postgres with context %}
{% if 'use_upstream_repo' in pillar.get('postgres') %} <======================
install-postgresql-repo:
pkgrepo.managed:
- humanname: PostgreSQL Official Repository
- name: {{ postgres.pkg_repo }}
- keyid: B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
[...]
---
local:
Data failed to compile:
----------
Rendering SLS 'base:postgres' failed: Jinja error: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 286, in render_jinja_tmpl
output = template.render(**unicode_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 3, in top-level template code
TypeError: argument of type 'NoneType' is not iterable
; line 3
---
{% from "postgres/map.jinja" import postgres with context %}
{% if 'use_upstream_repo' in pillar.get('postgres') %} <======================
install-postgresql-repo:
pkgrepo.managed:
- humanname: PostgreSQL Official Repository
- name: {{ postgres.pkg_repo }}
- keyid: B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
[...]
---
Which is seems to be fixed if I apply the change @iggy suggested. It is needed for the ID install_postgresql too though.
agree with @rmoorman - #42 must be merged.
Merged!
hi, there is issue with 'use_upstream_repo' pillar variable: this time it used like:
{% if 'use_upstream_repo' in pillar.get('postgres') %} install-postgresql-repo: .... omit some strings .... {% endif %}
but such usage checks only existence of variable in pillar but not its value. looks like it should be something like this:{% if 'use_upstream_repo' in pillar.get('postgres') %} {% if salt['pillar.get']('postgres:use_upstream_repo', False) %} install-postgresql-repo: .... omit some strings .... {% endif %} {% endif %}