Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2017 21:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/729244056606a48b0ee9161ace6beebb to your computer and use it in GitHub Desktop.
Salt/Jinja variable scope question
{% do foo.update(pillar.get('foo', {})) %}
{% set included_files = foo.get('included_files', {}) %}
{% for included_file,spec in included_files.items() -%}
{{ foo.get('config-path', '/etc') }}/foo.d/{{ included_file }}:
file.managed:
- template: jinja
- source: salt://foo/files/bar
# Can the template 'bar' use {{ included_file }} ??
@whytewolf
Copy link

whytewolf commented May 30, 2017

{% do foo.update(pillar.get('foo', {})) %} 
{% set included_files = foo.get('included_files', {}) %} 
{% for included_file,spec in included_files.items() -%}
{{ foo.get('config-path', '/etc') }}/foo.d/{{ included_file }}:
  file.managed:
    - template: jinja
    - source: salt://foo/files/bar
    - context:
        - included_file: {{included_file}}

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