I am having trouble using the file lookup plugin with a playbook that use
two roles:
roles:
- { role: role_1 }
- { role: role_Z }
"role_1" sets a variable using the lookup plugin in: role_1/vars/main.yml:
file_contents: "{{ lookup('file', 'config') }}"
I am able to correctly list the contents from: role_1/tasks/main.yml:
- debug: msg="the contents of config is: {{ file_contents }}"
when i try to use the variable from role_Z/tasks/main.yml, ansible throws
an error:
- debug: msg="the contents of config is: {{ file_contents }}"
FAILED! => {"failed": true, "msg": "the file_name '/path/to/basedir/config'
does not exist, or is not readable"}
I was expecting that "{{ file_contents }}" would have the actual contents
of the file as a string, but it seems that it is actually a closure
(future?) instead, and when it is used in "role_Z", the closure is called
and the path is now incorrect because the file does not exist in "role_Z".
Is there a way to force the execution of "lookup()" so that I can get the
actual file contents as a string rather than a closure?
--
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/8e002c1c-ceaa-483f-89c6-e4e1edd9b0ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.