Interview Prep/Ansible/Project Structure and Design

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.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design