lookup("template") but only if template exists

I used to be able to do this in order to construct EC2 instance user data from a template, but only if the template file existed – otherwise, leave the user data empty.

  • name: create {{ description }} instance
    ec2:

[…]
user_data: '{{ lookup(“template”,

“…/templates/user_data/” + instance + “.j2”)

default(None) }}’

I think I was actually taking advantage of the fact that the lookup plugin used to silently eat template errors (is that right?), but no longer does – now I get

TASK: [aws-ec2 | create Data Importer instance] *********************************
fatal: [aws-vpc-hbi16058] => unable to read /Users/bam/dev/h3-ansible/roles/aws-ec2/templates/user_data/data-importer.j2

Is there another way I can accomplish this sort of lookup-template-but-only-if-it-exists?