`command` failed 'No such file or directory' on a `~` path — the command module doesn't expand `~`/`$HOME`. Root cause: The `command` module runs no shell, so `~` isn't expanded. The fix: Use full paths, or the `shell` module when you need shell features.
A production war story from the TheCodeForge Ansible series — the incident, why it happened, and the exact fix.
⏳ Timestamps:
0:00 - Cold open: 'No such file or directory' for a file that exists
0:10 - Intro
0:17 - What Are They?
0:42 - Command vs Shell
1:18 - The Raw Module
1:55 - The Script Module
2:27 - Idempotency Flags
3:01 - Avoid Shell for Everything
3:37 - Environment & Working Dir
4:13 - Error Handling
4:46 - Security: Shell Injection
5:24 - 'No such file or directory' for a file that exists
5:50 - Missing creates flag
6:01 - The Fix
6:25 - ⚠ Gotcha: Using shell for destructive ops without creates
6:41 - ⚠ Gotcha: Forgetting `creates` on destructive commands
6:58 - ⚠ Gotcha: Using `command` with `$HOME` or `~`
7:10 - ⚠ Gotcha: Expecting `creates` to work with raw
7:27 - Version Compatibility: `creates`/`removes` with `script`
7:56 - Why `raw` Lacks `creates`/`removes`
8:17 - Production Caveat: `shell` with `warn: false`
8:34 - Debugging Guide
8:52 - Interview Questions
9:10 - FAQ
9:25 - Key Takeaways
9:39 - Next up
9:55 - Wrap-up
👉 Full article + code: https://thecodeforge.io/devops/ansibl...
⏭ Next up: Ansible Dynamic Inventory
#ansible #devops #automation