Interview Prep/Ansible/Modules, Idempotency and Handlers

`Could not find or access 'nginx.conf.j2' Searched in: .../roles/nginx/templates/nginx.conf.j2 ...`

BeginnerTroubleshootingModules, Idempotency and Handlers
Answer

Likely causes → The file sits in the wrong folder (for example roles/nginx/files/), the case differs, or src includes the folder name (templates/nginx.conf.j2), which some layouts tolerate but which breaks when the task is moved.

Diagnose → The error lists every path Ansible searched. Compare them with find roles/nginx -name 'nginx.conf*'.

Fix → Put templates in roles/<role>/templates/ and static files in roles/<role>/files/, and refer to them by filename only.

Prevent → Use ansible-galaxy role init to create roles with the standard directory layout.

All Ansible questions Roadmap: Ansible

More on Modules, Idempotency and Handlers