What is your policy on `shell` and `command` tasks?
BeginnerProductionProject Structure and Design
Answer
Use a module whenever one exists. If none does, command over shell, and every such task must be idempotent through creates/removes/changed_when/failed_when, with a comment on why no module fits.
ansible-lint rules (no-changed-when, command-instead-of-module, risky-shell-pipe) fail the build when someone slips. Add set -o pipefail plus executable: /bin/bash when piping, because otherwise failure of the first command in a pipe is hidden.
More on Project Structure and Design
What does a production Ansible repository look like?BeginnerMonorepo or separate repos for roles? How do you decide?IntermediateHow do you structure inventories for dev, stage and prod?BeginnerHow do you prevent someone from running a playbook against production by accident?IntermediateWhat does "thin playbooks, fat roles" mean?IntermediateWhat makes a well-designed role?Intermediate