trouble use file lookup as variable

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?