<p dir="auto">Using {% raw %} in templates does not stop jinja2 variable substitution</p>
<ul dir="auto">
<li>ansible 1.4 -devel <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/4f139673865b713ad6b5e90aa79575a19b2b237e/hovercard" href="https://github.com/ansible/ansible/commit/4f139673865b713ad6b5e90aa79575a19b2b237e"><tt>4f13967</tt></a></li>
</ul>
<p dir="auto">[playbook.yml]</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- name: &quot;test raw template output&quot;
  hosts: localhost

  vars:
    myvar: &quot;foo&quot;

  tasks:
    - local_action: template src=&quot;mytemplate.j2&quot; dest=&quot;/tmp/myoutput.txt&quot;"><pre class="notranslate"><code class="notranslate">
---
- name: "test raw template output"
  hosts: localhost

  vars:
    myvar: "foo"

  tasks:
    - local_action: template src="mytemplate.j2" dest="/tmp/myoutput.txt"
</code></pre></div>
<p dir="auto">[mytemplate.j2]</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Test: Preserve curly braces, and NOT perform variable substitution:

First Attempt:
{% raw %}
  - { include: &quot;{{ myvar }}&quot; }
{% endraw %}"><pre class="notranslate"><code class="notranslate">Test: Preserve curly braces, and NOT perform variable substitution:

First Attempt:
{% raw %}
  - { include: "{{ myvar }}" }
{% endraw %}
</code></pre></div>
<p dir="auto">[/tmp/myoutput.txt]</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Test: Preserve curly braces, and NOT perform variable substitution:


First Attempt:

  - { include: &quot;foo&quot; }"><pre class="notranslate"><code class="notranslate">Test: Preserve curly braces, and NOT perform variable substitution:


First Attempt:

  - { include: "foo" }
</code></pre></div>
<p dir="auto">NOTE: template output performs variable substitution even inside the {% raw %} block.</p>
<p dir="auto">REFERENCE: Workaround suggested by Brian Coa <a href="https://groups.google.com/forum/#!topic/ansible-project/Bn1ZFu5Pfb0" rel="nofollow">https://groups.google.com/forum/#!topic/ansible-project/Bn1ZFu5Pfb0</a></p>
<p dir="auto">I have a variable <code class="notranslate">hbase_standalone</code> that's set to <code class="notranslate">false</code> in defaults but for my current host it's <code class="notranslate">true</code>. And here's how my dependencies look like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dependencies:
  - { role: hadoop, when: not hbase_standalone }
  - { role: oracle-jdk }"><pre class="notranslate"><code class="notranslate">dependencies:
  - { role: hadoop, when: not hbase_standalone }
  - { role: oracle-jdk }
</code></pre></div>
<p dir="auto">So <code class="notranslate">hadoop</code> role is not included, that's fine, but <code class="notranslate">oracle-jdk</code> is also ignored! Works fine if I change the order though:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dependencies:
  - { role: oracle-jdk }
  - { role: hadoop, when: not hbase_standalone }"><pre class="notranslate"><code class="notranslate">dependencies:
  - { role: oracle-jdk }
  - { role: hadoop, when: not hbase_standalone }
</code></pre></div>
<p dir="auto">Mac OS, ansible 1.8.1.</p>