Reference collection root in role

How can I do something like this from within a ROLE:

handlers:

  • import_tasks: {{ collection_dir}}/handlers/apache.yaml

I see that doing this in a playbook that references the collection does work however there are two things broken with using it like this:

  1. It makes all of the roles dependent on the playbook having a specific handlers section, they are no longer self-contained.

  2. Molecule doesn’t know what to do with this and I can’t figure out how to test a role when the handlers don’t exist in the role.

Thanks,
-Mark

BTW, looks like freenode is down.

Hi,

how about using `role_dir`? Then you can use that to compose a relative
path from the current role's directory to your shared handlers file.

BTW, looks like freenode is down.

We've moved to Libera.chat (since three weeks now; see
https://github.com/ansible-community/community-topics/issues/19). It
took a while to get all docs updated (probably some are still missing),
but the official docs now point to Libera.chat:
https://docs.ansible.com/ansible/latest/community/communication.html#irc-channels

Cheers,
Felix

Yes I have been trying role_dir with a relative path but it’s not been working. Can I include a handlers section in the playbook tasks? That’s been the point of confusion for me.

I will update my bookmarks for libra chat. Thanks for the update.

-Mark

Excuse me, I meant to say:

Can I include a handlers section in the role tasks?