Shell pre check command

10 views
Skip to first unread message

Omar

unread,
Feb 1, 2022, 9:33:43 AM2/1/22
to Ansible Project

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?
Reply all
Reply to author
Forward
0 new messages