Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

salt variables are overwritten all over the place #89

Closed
iggy opened this issue Jan 13, 2015 · 6 comments
Closed

salt variables are overwritten all over the place #89

iggy opened this issue Jan 13, 2015 · 6 comments

Comments

@iggy
Copy link
Contributor

iggy commented Jan 13, 2015

i.e. {% set salt = .... BAD!~!!!

@aboe76
Copy link
Member

aboe76 commented Jan 13, 2015

@iggy, please explain further?

@iggy
Copy link
Contributor Author

iggy commented Jan 13, 2015

Apparently I was looking at a rather old clone. My bad.

@iggy iggy closed this as completed Jan 13, 2015
@iggy
Copy link
Contributor Author

iggy commented Mar 16, 2015

I was actually correct the first time. Just wasn't thinking when I was asked for clarification.

{% from "salt/map.jinja" import salt with context %}

That overwrites the predefined jinja variable "salt", thereby making it impossible to access members of that dict (i.e. salt['grains.get']() fails)

@iggy iggy reopened this Mar 16, 2015
@nmadhok
Copy link
Member

nmadhok commented Mar 16, 2015

@iggy Can you please explain further what's happening?

@iggy
Copy link
Contributor Author

iggy commented Mar 16, 2015

Pretty much every file has the following at the top:

{% from "salt/map.jinja" import salt with context %}

That overwrites the main salt jinja variable. So anything you would normally use {{ salt }} for stops working.

i.e. {{ salt['pillar.get']('salt:foo_setting') }} <-- no workie

@puneetk
Copy link
Contributor

puneetk commented Mar 16, 2015

I think iggy is recommending instead of possibly over writing the global {{ salt }} variable, we use a different variable name in the files. So instead of

{% from "salt/map.jinja" import salt with context %}

We use an explicit variable which wont have collisions like

{% from "salt/map.jinja" import salt_settings with context %}

or

{% from "salt/map.jinja" import salt as salt_settings with context %}

Among other things, it makes the templates readable and the scope of the settings variable clearer.

@nmadhok nmadhok closed this as completed Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants