Ansible shell module failure?

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? 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

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.