<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">Ansible core</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">ansible 2.2.1.0</p>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">deafult, installed from Ansible ppa</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Looks like new version of Ansible 2.2.1 fails in some cases when processing playbooks and templates<br>
that have quotation<br>
Previous version 2.2.0 works fine</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">this is from Kargo playbook, ansible playbook to install Kubernetes<br>
works with Ansible 2.2.0 and fails with 2.2.1</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Register docker images info
  shell: &quot;{{ docker_bin_dir }}/docker images -q | xargs {{ docker_bin_dir }}/docker inspect -f {% raw %}'{{.RepoTags}},{{.RepoDigests}}'{% endraw %}&quot;
  register: docker_images_raw
  failed_when: false
  when: not download_always_pull|bool"><pre class="notranslate"><code class="notranslate">- name: Register docker images info
  shell: "{{ docker_bin_dir }}/docker images -q | xargs {{ docker_bin_dir }}/docker inspect -f {% raw %}'{{.RepoTags}},{{.RepoDigests}}'{% endraw %}"
  register: docker_images_raw
  failed_when: false
  when: not download_always_pull|bool
</code></pre></div>
<p dir="auto">this works for 2.2.1</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Register docker images info
  raw: &gt;-
    {{ docker_bin_dir }}/docker images -q | xargs {{ docker_bin_dir }}/docker inspect -f &quot;{{ '{{' }} .RepoTags {{ '}}' }},{{ '{{' }} .RepoDigests {{ '}}' }}&quot;
  register: docker_images_raw
  failed_when: false
  when: not download_always_pull|bool"><pre class="notranslate"><code class="notranslate">- name: Register docker images info
  raw: &gt;-
    {{ docker_bin_dir }}/docker images -q | xargs {{ docker_bin_dir }}/docker inspect -f "{{ '{{' }} .RepoTags {{ '}}' }},{{ '{{' }} .RepoDigests {{ '}}' }}"
  register: docker_images_raw
  failed_when: false
  when: not download_always_pull|bool
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">At least some notes to Release Notes for 2.2.1 changes about quotation</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">I have automatic installation of Ansible from PPA, but with new version my roles are completely broken<br>
and need to be reviewed/refactored.<br>
Moreover, 2.2.0 is removed from PPA, so for me it is really disaster and work stopper.</p>
<p dir="auto">Can you please put 2.2.0 back in PPA and PLEASE note in case of such  significant changes.</p>
<p dir="auto">Thanks!</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">shell module with {% raw %} tags</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A (CentOS 7.2 shouldn't be platform specific)</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">This is quite meta .. but I will try and explain.</p>
<p dir="auto">We use the ansible shell command to run some commands against docker hosts which uses dockers --format feature that feature relies on GO template engine. Naturally we see conflicting behaviour here due to both jinja2 and go using '{{' as delimeters. AFAIK neither of these tools currently support switching delimeters but I may be wrong as that would be one way we could work around this..</p>
<p dir="auto">We pass a {% raw %}{% endraw %} wrapped go template to a shell module calling docker like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  - name: Count running images to check if down scaling is necessary
    shell:
      &quot;docker ps -a --no-trunc --filter name=^/{{artifact.namespace}}-{{ artifact.name }} --format='{% raw %}{{.ID}},{{.Image}}{% endraw %}' | wc -l&quot;
    register: docker_container_count

  - name: Debug the count
    debug:
      msg: &quot;{{ docker_container_count }}&quot; "><pre class="notranslate"><code class="notranslate">  - name: Count running images to check if down scaling is necessary
    shell:
      "docker ps -a --no-trunc --filter name=^/{{artifact.namespace}}-{{ artifact.name }} --format='{% raw %}{{.ID}},{{.Image}}{% endraw %}' | wc -l"
    register: docker_container_count

  - name: Debug the count
    debug:
      msg: "{{ docker_container_count }}" 
</code></pre></div>
<p dir="auto">The command executes successfully in both Ansible 2.1.1.0 and Ansible 2.2.1.0<br>
<strong>however</strong><br>
The internal representation 'cmd' key representing the original command was stored using the jinja tags as '{#'  and now it is being stored verbatim like '{{'. This is causing any further usage of this registered variable to fail as jinja is trying to parse the 'cmd' string.</p>
<p dir="auto">debug output before upgrade (v2.1.1.0):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="16:33:28 TASK [microservices : Debug the count] *************************
16:33:28 ok: [hostname.company.org] =&gt; {
16:33:28     &quot;msg&quot;: {
16:33:28         &quot;changed&quot;: true, 
16:33:28         &quot;cmd&quot;: &quot;docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{#.ID#},{#.Image#}' | wc -l&quot;, 
16:33:28         &quot;delta&quot;: &quot;0:00:00.025972&quot;, 
16:33:28         &quot;end&quot;: &quot;2017-01-23 16:33:27.970780&quot;, 
16:33:28         &quot;rc&quot;: 0, 
16:33:28         &quot;start&quot;: &quot;2017-01-23 16:33:27.944808&quot;, 
16:33:28         &quot;stderr&quot;: &quot;&quot;, 
16:33:28         &quot;stdout&quot;: &quot;1&quot;, 
16:33:28         &quot;stdout_lines&quot;: [
16:33:28             &quot;1&quot;
16:33:28         ], 
16:33:28         &quot;warnings&quot;: []
16:33:28     }
16:33:28 }
16:33:28 "><pre class="notranslate"><code class="notranslate">16:33:28 TASK [microservices : Debug the count] *************************
16:33:28 ok: [hostname.company.org] =&gt; {
16:33:28     "msg": {
16:33:28         "changed": true, 
16:33:28         "cmd": "docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{#.ID#},{#.Image#}' | wc -l", 
16:33:28         "delta": "0:00:00.025972", 
16:33:28         "end": "2017-01-23 16:33:27.970780", 
16:33:28         "rc": 0, 
16:33:28         "start": "2017-01-23 16:33:27.944808", 
16:33:28         "stderr": "", 
16:33:28         "stdout": "1", 
16:33:28         "stdout_lines": [
16:33:28             "1"
16:33:28         ], 
16:33:28         "warnings": []
16:33:28     }
16:33:28 }
16:33:28 
</code></pre></div>
<p dir="auto">debug output after upgrade (v2.2.1.0):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="16:07:24 TASK [microservices : Debug the count] ***********************************
16:07:24 fatal: [hostname.company.org]: FAILED! =&gt; 
{&quot;failed&quot;: true, 
   &quot;msg&quot;: &quot;{
     u'cmd': u\&quot;docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{{.ID}},{{.Image}}' | wc -l\&quot;, 
     u'end': u'2017-01-23 16:07:24.798553', 
     u'stdout': u'1', 
     u'changed': True, 
     u'start': u'2017-01-23 16:07:24.763174', 
     u'delta': u'0:00:00.035379', 
     u'stderr': u'', 
     u'rc': 0, 
     'stdout_lines': [u'1'], 
     u'warnings': []}: 
  template error while templating string: unexpected '.'. String: docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{{.ID}},{{.Image}}' | wc -l&quot;
}
16:07:24 	to retry, use: --limit @/home/jenkins/workspace/DeploymentFolder/DeployEdgeServer/rolling_deployment.retry
16:07:24 "><pre class="notranslate"><code class="notranslate">16:07:24 TASK [microservices : Debug the count] ***********************************
16:07:24 fatal: [hostname.company.org]: FAILED! =&gt; 
{"failed": true, 
   "msg": "{
     u'cmd': u\"docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{{.ID}},{{.Image}}' | wc -l\", 
     u'end': u'2017-01-23 16:07:24.798553', 
     u'stdout': u'1', 
     u'changed': True, 
     u'start': u'2017-01-23 16:07:24.763174', 
     u'delta': u'0:00:00.035379', 
     u'stderr': u'', 
     u'rc': 0, 
     'stdout_lines': [u'1'], 
     u'warnings': []}: 
  template error while templating string: unexpected '.'. String: docker ps -a --no-trunc --filter name=^/edge-server--account-service --format='{{.ID}},{{.Image}}' | wc -l"
}
16:07:24 	to retry, use: --limit @/home/jenkins/workspace/DeploymentFolder/DeployEdgeServer/rolling_deployment.retry
16:07:24 
</code></pre></div>