# Ansible command succeeded but playbook failed

**URL:** <https://forum.ansible.com/t/ansible-command-succeeded-but-playbook-failed/20461>\
**Category:** Ansible Developer\
**Created:** [February 5, 2016, 8:31am UTC](https://forum.ansible.com/t/ansible-command-succeeded-but-playbook-failed/20461 "2016-02-05T08:31:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaycoolzhao](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@jaycoolzhao](https://forum.ansible.com/u/jaycoolzhao)\
**Post date:** [February 5, 2016, 8:31am UTC](https://forum.ansible.com/t/ansible-command-succeeded-but-playbook-failed/20461/1 "2016-02-05T08:31:47Z")

</div>

Hi,

When I execute ansible command, it return success result:

root@\*\*\*\*temps# ansible release -m raw -u root -a “pwd” -c paramiko -k  
SSH password:  
10.170.124.24 | SUCCESS | rc=0 \>\>  
/root

But if I write this module to playbook, it could not work. See the yml:  
root@\*\*\*\*/temps# vim test\_spit.yml

**- hosts: release**  
**remote\_user: root**  
**tasks:**  
**- name: Hello**  
**raw: pwd**  
**register: hello**  
**- debug: msg={{ hello.stdout }}**  
**- debug: var=hello**

Result:

root@\*\*\*\*/temps# ansible-playbook test\_spit.yml -c paramiko -k  
SSH password:

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

**fatal: [10.170.124.24]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Traceback (most recent call last):\r\n File "/root/.ansible/tmp/ansible-tmp-1454657696.94-60833346390899/setup", line 198, in \r\n import shlex\r\nImportError: No module named shlex\r\n”, “parsed”: false}**  
NO MORE HOSTS LEFT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

10.170.124.24 : ok=0 changed=0 unreachable=0 failed=1

Do you have any comments for this issue? I appreciate your help.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 5, 2016, 12:34pm UTC](https://forum.ansible.com/t/ansible-command-succeeded-but-playbook-failed/20461/2 "2016-02-05T12:34:03Z")

</div>

The problem is that by default Ansible runs the setup module as part of gathering facts phase when running a playbook. An ad-hoc command is only running the specified module.

It appears that your remote Python install is missing the shlex module.

I am guessing that since you are trying to run the raw module that you may be somewhat aware of this.

Anyway, to keep the setup module from running during a playbook, you need to add `gather_facts: false` to your play definition.
