title: saltstack jinja2 nested template inheritance
body: <p>I'm having some issues with nested template inheritance in saltstack.</p>
  
  <p>I'm expecting <em>create_mon</em> to pass the string 'ceph_mon_config' to <em>create</em>, which then pulls the values of cpu, mem, etc. in the 'ceph_mon_config pillar to <em>prepare</em>, which does the heavy lifting.  As it stands now when the renderer reaches:</p>
  
  <pre><code>{% block cpu %}{{ pillar['{% block pillar_id %}{% endblock pillar_id %}']['cpu'] }}{% endblock cpu %}
  </code></pre>
  
  <p>It looks like it is interpreting it literally:</p>
  
  <pre><code>Rendering SLS 'base:/apps/ceph/create-mon' failed: Jinja variable 'salt.pillar object' has no attribute '{% block pillar_id %}{% endblock pillar_id %}'
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>
  
  <p><em>create_mon.sls</em></p>
  
  <pre><code>{% extends "states/system/vm/create.sls" %}
  
  {% block pillar_id %}ceph_mon_config{% endblock pillar_id %}
  
  virsh create /kvmfs/vms/{{ pillar['ceph_mon_config']['hostname'] }}/config.xml:
    cmd.run:
      - requires:
        - sls: /states/system/vm/create
  </code></pre>
  
  <p><em>create.sls</em></p>
  
  <pre><code>{% extends "states/system/vm/prepare.sls" %}
  
  {% block cpu %}{{ pillar['{% block pillar_id %}{% endblock pillar_id %}']['cpu'] }}{% endblock cpu %}
  {% block mem %}{{ pillar['ceph_mon_config']['mem'] }}{% endblock mem %}
  {% block network %}{{ pillar['ceph_mon_config']['network'] }}{% endblock network %}
  {% block os %}{{ pillar['ceph_mon_config']['os'] }}{% endblock os %}
  {% block hostname %}{{ pillar['ceph_mon_config']['hostname'] }}{% endblock hostname %}
  {% block disk %}{{ pillar['ceph_mon_config']['disk'] }}{% endblock disk %}
  </code></pre>
  
  <p><em>prepare.sls</em></p>
  
  <pre><code>/kvmfs/vms/{% block hostname %}{% endblock hostname %}/config.xml:
    file.managed:
      - source: https://git.cybbh.space/vta/saltstack/raw/master/apps/virsh/files/common.xml
      - makedirs: True
      - template: jinja
      - skip_verify: True
      - defaults:
          name: {{ self.hostname() }}
          mem: {% block mem %}{% endblock mem %}
          cpu: {% block cpu %}{% endblock cpu %}
          network: {% block network %}{% endblock network %}
  
  /kvmfs/vms/{{ self.hostname() }}/disk0.qcow2:
    file.copy:
      - source: /kvmfs/images/{% block os %}{% endblock os %}-latest
  
  qemu-img resize /kvmfs/vms/{{ self.hostname() }}/disk0.qcow2 {% block disk %}{% endblock disk %}:
    cmd.run:
      - requires:
        - /kvmfs/vms/{{ self.hostname() }}/disk0.qcow2
  
  /kvmfs/vms/{{ self.hostname () }}/data/meta-data:
    file.managed:
      - source: https://git.cybbh.space/vta/saltstack/raw/master/apps/virsh/files/common.metadata
      - makedirs: True
      - template: jinja
      - skip_verify: True
      - defaults:
          hostname: {{ self.hostname() }}
  
  /kvmfs/vms/{{ self.hostname () }}/data/user-data:
    file.managed:
      - source: https://git.cybbh.space/vta/saltstack/raw/master/apps/virsh/files/common.userdata
      - makedirs: True
      - skip_verify: True
  
  genisoimage -o /kvmfs/vms/{{ self.hostname () }}/config.iso -V cidata -r -J /kvmfs/vms/{{ self.hostname () }}/data/meta-data /kvmfs/vms/{{ self.hostname () }}/data/user-data:
    cmd.run:    
      - requires:
        - /kvmfs/vms/{{ self.hostname () }}/data/metadata
        - /kvmfs/vms/{{ self.hostname () }}/data/userdata
  </code></pre>