How to do lookup a dynamic filename?

481 views
Skip to first unread message

Eddie Welker

unread,
Jan 29, 2015, 4:56:23 PM1/29/15
to ansible...@googlegroups.com, Anastasiia Panchenko
Hi,

I'm trying to do something like the following in 'group_vars/all":

name: "{{ lookup('env', 'PROJECT_NAME') }}"
file: "{{ lookup('file', '{{name}}' ) }}"

but of course, the syntax above won't work. 

Is there an alternate way to do this?  I can't think of a way to accomplish this.

-e

Matt Martz

unread,
Jan 30, 2015, 7:27:09 PM1/30/15
to ansible...@googlegroups.com, Anastasiia Panchenko
You do not (and cannot) nest jinja print brackets

What you are looking for is:

file: "{{ lookup('file', name ) }}"

--
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/74698eda-cb3b-44c3-8c59-7314ed126209%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Reply all
Reply to author
Forward
0 new messages