with_first_found and templates

340 views
Skip to first unread message

Josh Smift

unread,
Sep 3, 2014, 10:04:26 AM9/3/14
to ansible...@googlegroups.com
We've got a task like this:

- name: template TrustedHosts
template: dest=/etc/opendkim/TrustedHosts src={{ item }} backup=yes
with_first_found:
- TrustedHosts.{{ stack }}
- TrustedHosts.default

There are three hosts that use the playbook this is in, and when Ansible
gets to this task, it says

TASK: [../../shared/roles/opendkim | template TrustedHosts] *******************
fatal: [host3] => {'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}
fatal: [host2] => {'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}
fatal: [host3] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}]}
fatal: [host2] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}]}
fatal: [hos1] => {'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}
fatal: [host1] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': 'unable to read /home/jsmift/ansible/shared/roles/opendkim/templates', 'failed': True}]}

(Hostnames changed to protect the innocent.)

It works fine if I change it to

- name: template TrustedHosts
template: dest=/etc/opendkim/TrustedHosts src={{ item }} backup=yes
with_first_found:
- ../templates/TrustedHosts.{{ stack }}
- ../templates/TrustedHosts.default

That suggests to me that it's searching relative to the 'files' directory
of this role; I had expected it to search relative to the 'templates'
directory, since this task uses the template module.

Should the initial task work as written (i.e. is this a bug)? If not, is
there a better way to do this, or is "../templates" the right answer?

-Josh (j...@care.com)



This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

Michael DeHaan

unread,
Sep 3, 2014, 12:15:30 PM9/3/14
to ansible...@googlegroups.com
Hi Josh,

The various "with_" operators in ansible are generic so this shouldn't be specific to the template module, but that does seem a bit curious.

I amw ondering if it's because with_first_found is not returning an os.path.abspath or has some weird logic in there.

Can you please file a bug on this one so we can look at it?

Thanks!





--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/21511.8133.594908.208566%40gargle.gargle.HOWL.
For more options, visit https://groups.google.com/d/optout.

Josh Smift

unread,
Sep 3, 2014, 12:50:00 PM9/3/14
to ansible...@googlegroups.com
MD> Can you please file a bug on this one so we can look at it?

Done: https://github.com/ansible/ansible/issues/8879 (from my personal
account, I don't have a work-related Github account at the moment).

Thanks!

Michael DeHaan

unread,
Sep 4, 2014, 9:17:21 PM9/4/14
to ansible...@googlegroups.com
Thanks, I've prioritized this one up a bit, will reply on the ticket as this progresses.  Thanks!


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages