title: Ansible: do not run shell command if a file exists
body: <p>I would like to do the following in an Ansible playbook:</p>
  
  <pre><code>- name: "Generate variant html report"
    shell: "&lt;my command&gt;"
    with_items: "{{ variants | default([]) }}"
    when: ({{ folderReports }}/{{ item }}).exists == False
  </code></pre>
  
  <p>Inside the <code>when</code>, I need a way to create the file path, and determine if it exists or not. I tried to use the "(" ")" to surround my first expression, but it doesn't seem to be working:</p>
  
  <blockquote>
    <p>2016-10-13 16:22:48,130 p=94292 u=sautomation |  fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check '({{ folderReports }}/{{ item }}).exists == True' failed. The error was: template error while templating string: unexpected '/'. String: {% if (/opt/diff-test1.diff).exists == True %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/opt/ansible/roles/stats/tasks/main.yml': line 45, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Generate report\"\n  ^ here\n"}</p>
  </blockquote>