# Ansible shell module failure?

**URL:** <https://forum.ansible.com/t/ansible-shell-module-failure/23086>\
**Category:** Ansible Project\
**Created:** [November 23, 2016, 7:04pm UTC](https://forum.ansible.com/t/ansible-shell-module-failure/23086 "2016-11-23T19:04:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![burns498](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@burns498](https://forum.ansible.com/u/burns498)\
**Post date:** [November 23, 2016, 7:04pm UTC](https://forum.ansible.com/t/ansible-shell-module-failure/23086/1 "2016-11-23T19:04:44Z")

</div>

Hello - Assistance requested

I’m encountering a shell module failure in a play I’m testing. My end goal is to validate if my app “MIP” is down or not. Plan is to check for the running process, then conditionally fail out as needed. My sample shell command is failing but I can’t determine why. The actual error output isn’t helpful.

Code:

`

- name: Validate MIP is down  
hosts: “{{ target }}”  
tasks:
- shell: “ps -ef | grep ‘/apps/scope/manh/MIP/profile-root’ | grep -v grep”

# - shell: “ps -ef | grep ‘{{ MIP\_HOME }}/profile-root’ | grep -v grep”

register: mip\_output  
changed\_when: false

`

Error Output:

> wmspt@dtl01lnxap01a:/manh$ ansible-playbook pb-running-validation.yml --extra-vars “target=Test5 ant\_handlers=false” -vvv

> Using /manh/ansible.cfg as config file  
> PLAYBOOK: pb-running-validation.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> 1 plays in pb-running-validation.yml  
> PLAY [Validate MIP is down] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \<…\>  
> ok: [ptl01a0fap006]  
> TASK [command] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> task path: /manh/pb-running-validation.yml:7  
> \<…\>  
> fatal: [ptl01a0fap006]: FAILED! =\> {“changed”: false, “cmd”: “ps -ef | grep ‘/apps/scope/manh/MIP/profile-root’ | grep -v grep”, “delta”: “0:00:00.125571”, “end”: “2016-11-23 12:58:48.369056”, “failed”: true, “invocation”: {“module\_args”: {“\_raw\_params”: “ps -ef | grep ‘/apps/scope/manh/MIP/profile-root’ | grep -v grep”, “\_uses\_shell”: true, “chdir”: null, “creates”: null, “executable”: null, “removes”: null, “warn”: true}, “module\_name”: “command”}, “rc”: 1, “start”: “2016-11-23 12:58:48.243485”, “stderr”: “”, “stdout”: “”, “stdout\_lines”: , “warnings”: }

The command itself works fine when executed manually on the target server.

Perhaps it’s something with the [shell module](http://docs.ansible.com/ansible/shell_module.html)? It looks like shell module is frowned upon based on the docs. Perhaps there is a way to turn this command into something that the actually command module can parse.

Thanks

---

<div class="post-metadata">

**Author:** ![burns498](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@burns498](https://forum.ansible.com/u/burns498)\
**Post date:** [November 23, 2016, 8:48pm UTC](https://forum.ansible.com/t/ansible-shell-module-failure/23086/2 "2016-11-23T20:48:36Z")

</div>

So I took the shell command piece by piece, and it looks like it was failing due to two pipes strung together. Once I slimmted it down to ps -ef | grep ‘/apps/scope/manh/MIP/profile-root’ it worked fine. My following conditional then handles the extra grep PID that it returns now.
