Lookup plugins relative directories fixed up for 1.2 roles - 1.2 playbooks may require some adaptation

I’ve recently made a change such that lookup plugins when used with roles or included files now understand role directories.

See here:

https://github.com/ansible/ansible/issues/2697

This means that within a role if you use {{ lookup(‘file’,‘foo’) }} or even:

  • action: shell echo {{ item }}

with_file:

  • foo

It will look to see if there is a roles structure available to find the file. It will look in ‘files’ if available, and if not available, it will look in the same directory as the original file.

I am mentioning this as it MAY cause users of roles some need to adapt any “…/” logic in their 1.2 playbooks.

For most people though, it will appear that roles “just work” like they should, so I hope this is a welcome improvement!

Hi Michael,

Great, thanks.
I spent about 1 hour to analyse the code to fix this bug :wink:

Peter

Hi,

Check out and maybe reopen https://github.com/ansible/ansible/issues/2697, because it is causing “unsolvable?” issues.

Thanks,
gw

I’ve commented on the ticket.

The problem here is you have a directory named ‘files’ locally, so the file lookup plugin is trying to look in a path relative to this.

This is done to support roles, because now the file lookup plugin will look in the role’s ‘files’ directory, rather than just looking in the dot directory.

Your problem seems to be that you have an extra ‘files’ directory somewhere, so it’s trying to look inside of it.