locations for the "lookup('file'...)

39 views
Skip to first unread message

Dmitry Makovey

unread,
Jul 23, 2014, 4:48:18 PM7/23/14
to ansible...@googlegroups.com
Hi,

I'm trying to get through my "slow" day here - can't figure out (or locate documetation explaining it) - where does "lookup('file',...)" looks indeed.

I have a structure:

group_vars/all.yml
pgsql_key
pgsql_key.pub
roles/pgsql/tasks/main.yml
site.yml

under all.yml I have var defined:
...
pgsql_ssh_key="pgsql_key"
...

inside of roles/pgsql/tasks/main.yml I have:

...
debug: var=pgsql_ssh_key
debug: msg={{ lookup('file',pgsql_ssh_key) }}
...

site.yml is simple:

- hosts: pgsql
  roles:
  - pgsql

however I get empty contents of lookup call while debug for the pgsql_ssh_key returns proper value. Seems like lookup wants to pick up my pgsql_ssh_key under roles/pgsql/files, but I'd like to keep it top-level (other roles will be using it). What did I miss?

Michael DeHaan

unread,
Jul 23, 2014, 6:12:12 PM7/23/14
to ansible...@googlegroups.com
It looks relative to the playbook root, and if in roles, will look in the "files/" dir of roles.

If you try it and it can't find something, it will tell you where it looked.




--
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/aafcc319-4242-46ac-9837-79f6629d5571%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitry Makovey

unread,
Jul 23, 2014, 7:41:02 PM7/23/14
to ansible...@googlegroups.com


On Wednesday, July 23, 2014 4:12:12 PM UTC-6, Michael DeHaan wrote:
It looks relative to the playbook root, and if in roles, will look in the "files/" dir of roles.

I've noticed that it does look in role's "files" dir but apparently it doesn't look at playbook root. Is there a parameter I tweaked someplace?
 

If you try it and it can't find something, it will tell you where it looked.


tells me it can't find it in roles/pgsql/files 

Michael DeHaan

unread,
Jul 24, 2014, 7:12:11 AM7/24/14
to ansible...@googlegroups.com
It won't look in the playbook root when inside a role, no.    Sorry I mispoke on that one.

You can path the src as {{ lookup('file', playbook_dir + '/filename') }} if you want this, and it will find things there using the (derived) path of the playbook root.

Ansible will look in the root if you are not using roles.

Relative pathing would also find it.









--
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