title: Why does my Ansible playbook always return 'error'?
body: <p>When trying to run a playbook I always get an error. And I don't understand why I get the error.</p>
  
  <p>My Playbook</p>
  
  <pre><code>- hosts: 127.0.0.1
    gather_facts: no
    connection: local
  
    tasks:
      #Call ansible module "userinfo" with parameter "username="
      - name: 'Ansible module in shell'
        action: userinfo username=ansible
        register: userInfoVariable
  
      - name: 'Abort execution if user does not exist'
        fail: msg="User does not exist"
        when: userInfoVariable.isUserExist == False
  
      - name: 'Execute task if user exist'
        #action: someaction
        shell: echo 'User exist - Replace shell with your action here.'
        register: userExist
        when: userInfoVariable.isUserExist == True
  
      - debug: var=userExist
  </code></pre>
  
  <p>I want to run this shell-script as module</p>
  
  <pre><code>#!/bin/bash
  
  source ${1}
  
  if id -u $username &gt;/dev/null 2&gt;&amp;1; then
  isUserExist="True"
  else
  isUserExist="False"
  fi
  
  echo "changed=True msg=OK isUserExist='$isUserExist'"
  </code></pre>
  
  <p>And this is the result after running the playbook</p>
  
  <pre><code>18:14:38-admin@serv17:~/ans-playbooks$ ansible-playbook test-cust-module.yml
  
  PLAY [127.0.0.1] **************************************************************
  
  TASK: [Ansible module in shell] ***********************************************
  failed: [127.0.0.1] =&gt; {"failed": true, "parsed": false}
  changed=True msg=OK isUserExist='True'
  
  
  FATAL: all hosts have already failed -- aborting
  
  PLAY RECAP ********************************************************************
             to retry, use: --limit @/home/admin/test-cust-module.retry
  
  127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=1
  </code></pre>
  
  <p>My script is run based on this output</p>
  
  <pre><code>changed=True msg=OK isUserExist='True'
  </code></pre>
  
  <p>But this error is not expected</p>
  
  <pre><code>failed: [127.0.0.1] =&gt; {"failed": true, "parsed": false}
  </code></pre>
  
  <p>Why does it occur?</p>