title: Ansible item when clause throws error: Unable to look up a name or access an attribute in template string
body: <p>In the following task, I am getting the error message <code>Unable to look up a name or access an attribute in template string. Make sure your variable name does not contain invalid characters like '-'.</code> I have traced it down to the <code>when</code> clause.</p>
  
  <p>Using debug statements I have verified:</p>
  
  <ul>
  <li><code>mysql_server_version='5.2.23'</code></li>
  <li><code>mysql_client_version='5.2.23'</code></li>
  <li><code>mysql_version='5.2.23'</code></li>
  </ul>
  
  <p>If I remove the <code>when</code> statement, the task runs.</p>
  
  <pre><code> - name: download MySQL packages
     tags:
       - preosupdates
     when: "{{ mysql_server_version | version_compare(mysql_version, '&lt;') or mysql_client_version | version_compare(mysql_version, '&lt;') }}"
     command: yum update -y --downloadonly MySQL-server-advanced-{{ mysql_version }} MySQL-shared-compat-advanced-{{ mysql_version }} MySQL-client-advanced-{{ mysql_version }}
     register: downloadonly
     failed_when: downloadonly.rc not in (1, 0)
     changed_when: "downloadonly is defined and 'No Packages marked for Update' not in downloadonly.stdout"
  </code></pre>
  
  <h3>Versions</h3>
  
  <ul>
  <li>ansible-1.9.0.1</li>
  </ul>