I distilled the problem down to a simple YAML file:
`
- hosts: apps2
vars:
TOP_BAD: “…”
tasks:
- name: check TOP
debug: msg=“{{TOP}}”
handlers:
- include: “{{TOP}}/handlers/apache_graceful.yml”
`
When I save this in inc.yml and run this command:
ansible-playbook -i ../hosts inc.yml
I get this output:
ERROR: file could not read: /home/tekberg/src/ansible_scripts/provision_apps2/{{TOP}}/handlers/apache_graceful.yml
The actual problem is that the variable TOP is not defined, which should have been detected prior to trying to open the file. If I change TOP_BAD to TOP, the script runs to completion with no errors.
Why didn’t the interpolation code complain that TOP was undefined?