Ansible command succeeded but playbook failed

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.

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.