Thanks for the quick reply. That is definitely the behavior I've seen previously. Looking closer after your description of what happens, I note that the included tasks are being skipped. The failure is happening on a task that uses with_items, where the with_items line refers to the variable tested in the include/when.
Playbook/parent file:
- include: data-importer.yml
when: instances['data-importer'] is defined
Included file 1:
- include: instance-common.yml
description="Data Importer"
instance=data-importer
Included file 2:
- name: create {{ description }} instance
ec2:
[...]
with_items: instances[instance]["hostname"]
With this arrangement, I get
TASK: [aws-ec2 | create Data Importer instance] *******************************
fatal: [aws-vpc-hbi16058] => with_items expects a list or a set
So my problem seems to be specific to with_items and skipped tasks.
--Bret