title: Ansible and `changed_when` based on `stdout` value
body: <p>I am running a custom command because I haven't found a working module doing what I need, and I want to adjust the <code>changed</code> flag to reflect the actual behaviour:</p>
  
  <pre><code>- name: Remove unused images
    shell: '[ -n "$(docker images -q -f dangling=true)" ] &amp;&amp; docker rmi $(docker images -q -f dangling=true) || echo Ignoring failure...'
    register: command_result
    changed_when: "command_result.stdout == 'Ignoring failure...'"
  
  - debug: var="1 {{ command_result.stdout }}"
    when: "command_result.stdout != 'Ignoring failure...'"
  - debug: var="2 {{ command_result.stdout }}"
    when: "command_result.stdout == 'Ignoring failure...'"
  </code></pre>
  
  <p>(I know the shell command is ugly and could be improved by a more complex script but I don't want to for now)</p>
  
  <p>Running this task on an host where no Docker image can be removed gives the following output:</p>
  
  <pre><code>TASK: [utils.dockercleaner | Remove unused images] **************************** 
  changed: [cloud-host] =&gt; {"changed": true, "cmd": "[ -n \"$(docker images -q -f dangling=true)\" ] &amp;&amp; docker rmi $(docker images -q -f dangling=true) || echo Ignoring failure...", "delta": "0:00:00.064451", "end": "2015-07-30 18:37:25.620135", "rc": 0, "start": "2015-07-30 18:37:25.555684", "stderr": "", "stdout": "Ignoring failure...", "stdout_lines": ["Ignoring failure..."], "warnings": []}
  
  TASK: [utils.dockercleaner | debug var="DIFFERENT {{ command_result.stdout }}"] *** 
  skipping: [cloud-host]
  
  TASK: [utils.dockercleaner | debug var="EQUAL {{ command_result.stdout }}"] *** 
  ok: [cloud-host] =&gt; {
      "var": {
          "EQUAL Ignoring failure...": "EQUAL Ignoring failure..."
      }
  }
  </code></pre>
  
  <p>So, I have this stdout return value <code>"stdout": "Ignoring failure..."</code>, and the debug task shows the strings are equal, so <strong>why is the task still displayed as "changed"</strong>?</p>
  
  <p>I am using <code>ansible 1.9.1</code>.</p>
  
  <p>The documentation I am refering to is this one: <a href="http://docs.ansible.com/ansible/playbooks_error_handling.html#overriding-the-changed-result">http://docs.ansible.com/ansible/playbooks_error_handling.html#overriding-the-changed-result</a></p>