# Shell pre check command

**URL:** <https://forum.ansible.com/t/shell-pre-check-command/36268>\
**Category:** Ansible Project\
**Created:** [February 1, 2022, 2:33pm UTC](https://forum.ansible.com/t/shell-pre-check-command/36268 "2022-02-01T14:33:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@Omar](https://forum.ansible.com/u/Omar)\
**Post date:** [February 1, 2022, 2:33pm UTC](https://forum.ansible.com/t/shell-pre-check-command/36268/1 "2022-02-01T14:33:43Z")

</div>

When working with tools that don’t have an Ansible module/roles and only have shell commands to interact with. I find my self writing the following:

- shell: pre\_check\_command || command

Where ‘pre\_check\_command’ exits with 0 if the outcome of ‘command’ already exits. Unfortunately, such usage will always output [changed].

I know I can use multiple tasks with register and chagned\_when, but it feels like a lot lines for something that is common.

Anyone else seeing the same pattern when working with the shell module?  
Perhaps an additional argument for the shell module or is there an entirely different trick that I’m not seeing?
