IDEMPOTENCY - Are you command/shell grepping? #3335
Labels
area/idempotency
kind/cleanup
Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/question
Description
We do a lot of 'greps' in the code base. There is no grep module. And
lineinfile
will change files. This is not cool because running cmd/shell is overkill/hacky for just checking if a string is in a file.What can you do instead?
Take this snippet from playbooks/common/openshift-cluster/upgrades/post_control_plane.yml for example:
So, what do?
What can you do different? Use the
find
module instead.failed_when
because it's not necessary, if no files are matched the task won't fail, it will just report 0 forresults.matched
.changed: true
because it only inspects, never modifies. We don't rely on command return codes, we instead check the results of the task to see if there was a match.Got any thoughts?
The text was updated successfully, but these errors were encountered: