title: Ansible conditional based on contents of file
body: <p>Gratefully if someone could point out what's wrong with this…</p>
  
  <p>The following code is meant to setup a test in the register module that prints the current value of <code>/etc/timezone</code>.  There's then a task that compares that to the group/host {{ timezone }} variable and only runs the task if it's different (i.e. doesn't call handlers unnecessarily).</p>
  
  <p>But it always runs regardless.</p>
  
  <pre><code>- name: check current timezone
    shell: cat /etc/timezone
    register: get_timezone
  
  - name: set /etc/timezone
    shell: echo "{{ timezone }}" &gt; /etc/timezone
    when: get_timezone.stdout.find('{{ timezone }}') == false
    notify: update tzdata
  </code></pre>
  
  <p>....</p>
  
  <p>in group_vars/all.yml:</p>
  
  <pre><code>timezone: Europe/London
  </code></pre>