Sorry, that was just a typo in my example. The filenames all match.
On Tuesday, October 16, 2018 at 8:48:22 AM UTC-6, Matt Martz wrote:
>
> The template does not exist. You are using the wrong template file in
> your lookup call:
>
> ```
> - stuff: "{{ lookup('template', 'role_one_template.j2') }}"
> ```
>
> However, you have indicated the file is actually
> named: /roles/one/templates/role_one_template_file.j2
>
> On Mon, Oct 15, 2018 at 11:06 PM Dmitriy Panteleyev <[email protected]
> <javascript:>> wrote:
>
>> I'm a bit confused how variables are defined when using `include_role`.
>> A basic example follows.
>>
>> */play.yml*
>> - hosts: localhost
>> roles:
>> - one
>>
>>
>>
>> */roles/one/tasks/main.yml*
>> ---
>> - name: do a thing with another role
>> include_role:
>> name: two
>> vars:
>> passed_variable:
>> - stuff: "{{ lookup('template', 'role_one_template.j2') }}"
>>
>>
>> */roles/one/templates/role_one_template_file.j2*
>> bla bla bla bla
>> random bit of stuff
>> does not matter what
>>
>>
>> */roles/two/tasks/main.yml*
>> ---
>> - debug:
>> var: passed_variable
>>
>>
>> My expectation is that role "one" will pull the template and pass the
>> *results* of that lookup to role "two". However, when running the play,
>> I get first a warning, and then an error. It *seems* as if the template
>> lookup occurs in role "two". So, what exactly is going on, and how do I
>> fix it?
>>
>>
>> looking for "role_one_template.j2" at
>>> "/roles/two/templates/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/roles/two/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/templates/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/role_one_template.j2"
>>> [WARNING]: Unable to find 'role_one_template.j2' in expected paths (use
>>> -vvvvv to see paths)
>>
>> ...
>>> ...
>>
>> ERROR! An unhandled exception occurred while templating '{u'stuff': [{{
>>> lookup(\'template\', \'role_one_template.j2\') }}]}'.
>>> Error was a <class 'ansible.errors.AnsibleError'>, original message: An
>>> unhandled exception occurred while running the lookup plugin 'template'.
>>> Error was a <class 'ansible.errors.AnsibleError'>, original message: the
>>> template file role_one_template.j2 could not be found for the lookup
>>
>>
>>
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/16d95836-e93b-4e98-828d-9b4f176a0047%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/16d95836-e93b-4e98-828d-9b4f176a0047%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
--
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/caff13ff-e78a-4fd2-ba50-d48e2f7a79cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.