title: Ansible: Comparing a String with a register
body: <p>This script was intended to obtain the time zone on each server and store it in a register. After that I would compare the time zone stored in the register with the variable, time_zone, to see if all the servers are in PDT time. The second task shoulds print out all the servers that are not in PDT time, but the logic is completely opposite of what I intended. Currently, the second task runs when TZ != PDT and skips when TZ == PDT. I am running this locally and I'm currently in PDT time zone. </p>
  
  <pre><code>---
  - hosts: localhost
    gather_facts: no
  
    vars:
      time_zone: 'PDT'
  
    tasks:
  
    - name: Find the servers that are not in PDT time zone.
      shell: date | awk '{print $5}'
      register: TZ
    - debug: msg={{TZ.stdout}}
  
    - name: Display the servers that are not in PDT time zone. 
      shell: echo $HOSTNAME
      when: TZ != time_zone
  </code></pre>