Idempotency is a very desirable property of ansible code. An idempotent piece of code is one that re-run multiple times would always produce the same results and side effects.
In order to ensure this in ansible, we should avoid using the following modules, whenever possible:
command
shell
When command or shell are essential then we can still make the module idempotent by using one or more of the following constructs:
conditionals (when or assert module)
other control flow statements (always, rescue or fail)
Searching and checking idempotency of roles containing command and shell is the first step.
Idempotency is a very desirable property of ansible code. An idempotent piece of code is one that re-run multiple times would always produce the same results and side effects.
In order to ensure this in ansible, we should avoid using the following modules, whenever possible:
command
shell
When
command
orshell
are essential then we can still make the module idempotent by using one or more of the following constructs:when
orassert
module)always
,rescue
orfail
)Searching and checking idempotency of roles containing
command
andshell
is the first step.