`file: path=/var/www state=directory owner=www-data recurse=true` takes minutes and shows `changed`
IntermediateTroubleshootingModules, Idempotency and Handlers
Answer
Likely causes → recurse: true walks every file under the directory. On large trees (uploads, node_modules) this is slow, and any file the application created with a different owner is reported as changed.
Fix → Set ownership on the top-level directory only, and let the application create files with the right user (umask, a systemd User=). If a one-off recursive fix is needed, run it once behind a flag instead of on every run.
Prevent → Avoid recurse: true in roles that run regularly. Deploy release directories that already have the correct ownership.
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