File lookup within a role

8 views
Skip to first unread message

Ryan Kane

unread,
Aug 3, 2015, 12:58:32 PM8/3/15
to Ansible Project
Hi - I'm new to Ansible and trying to create a role that contains a file, the contents of which are passed to a second role.  

Example Structure:

RoleA

files
  - foo.txt

meta
  - main.yml

The contents of main.yml are:

---
dependencies:
  - {role: RoleB, data: "{{ lookup('file', 'foo.txt') }}"} 

Both RoleA and RoleB are located in /etc/ansible/roles

The playbook has a single site.yml that contains:

---
- hosts: all
  roles:
  - role: RoleA


What I expected to happen is that the tasks defined in Role B would be executed, and the variable "data" would resolve to the value contained in foo.txt.  

What I'm getting is: 

ERROR: Failed to template {{ lookup('file', 'foo.txt') }}: could not locate file in lookup: foo.txt

Any help/ideas on this would be greatly appreciated.
Reply all
Reply to author
Forward
0 new messages