`"msg": "Destination directory /etc/myapp does not exist"`
BeginnerTroubleshootingModules, Idempotency and Handlers
Answer
Likely causes → copy and template do not create parent directories.
Fix →
- ansible.builtin.file:
path: /etc/myapp
state: directory
owner: root
mode: "0755"
- ansible.builtin.template:
src: app.yml.j2
dest: /etc/myapp/app.yml
Prevent → Order tasks as directories, then files, then services.
More on Modules, Idempotency and Handlers
`ERROR! The requested handler 'Restart nginx' was not found in either the main handlers list nor in the listening handlers list`BeginnerA handler named `restart {{ app_service }}` is never found when notified as `restart myapp`AdvancedA `command` task reports `changed` on every run, and the Molecule idempotence check failsBeginner`curl ... | tar xz` fails on the host but the `shell` task reports successIntermediate`lineinfile` appends the same line again on every runIntermediate`lineinfile` with `backrefs: true` reports `ok` but the line was never addedIntermediate