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

jinja2 block rendering #11731

Closed
oc opened this issue Apr 2, 2014 · 1 comment
Closed

jinja2 block rendering #11731

oc opened this issue Apr 2, 2014 · 1 comment

Comments

@oc
Copy link

oc commented Apr 2, 2014

Distilled example:

!pillar/blah/init.sls

foos:
  - site: 'custom-site'
    custom_template: 'salt://foo/etc/foo/custom.conf.jinja'
    bar: False
  - site: 'default-site'

states/foo/init.sls:

{%- for foo in pillar['foos'] %}
/etc/foo/{{ foo.site }}.conf:
    - source: {{ foo.get('custom_template', 'salt://foo/etc/foo/default.conf.jinja') }}
    - template: jinja
    - context:
        {{ foo }}
    - defaults:
        bar: True
        baz: False
{%- endfor %-}

states/foo/etc/foo/default.conf.jinja

# Bla bla

{%- block override_this %}
# This should be overridden
This gets written
{%- endblock %}

# More bla

states/foo/etc/foo/custom.conf.jinja

{% extends "foo/etc/foo/site.conf.jinja" %}
# Deliberately set to be in the same path, just for clarity

{%- block overridde_this %}
# This should be written for custom-site
This should be {{bar}}...

{%- block %}

client (target) salt-call --versions-report

           Salt: 2014.1.1
         Python: 2.7.3 (default, Jan  2 2013, 13:56:14)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.10
   msgpack-pure: Not Installed
       pycrypto: 2.6
         PyYAML: 3.10
          PyZMQ: 13.1.0
            ZMQ: 3.2.3

master (target) salt-master --versions-report

           Salt: 2014.1.1
         Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.10
   msgpack-pure: Not Installed
       pycrypto: 2.6
         PyYAML: 3.10
          PyZMQ: 13.1.0
            ZMQ: 3.2.3
@oc
Copy link
Author

oc commented Apr 3, 2014

Works after updating to current head

@oc oc closed this as completed Apr 3, 2014
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

1 participant