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?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/68912602-172d-4614-98a0-d06ab3087df5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to