Conditional Roles and dependencies.

Hi,

I have been breaking my head on the following for the past few days now and I can’t come up with a clean solution that will keep my roles portable.
Effectively, what I want to do is have two role (webserver / monitoring), depending on whether the first one ran the second one should install an additional script.

The cleanest solution I came up with so far is to use the new magic ‘{{ role_names }}’ to determine whether a role was applied within that play, however
I have another separate playbook that only applies the ‘second’ role (monitoring), for the sake of easily updating all monitoring agents landscape wide, this play obviously doesn’t include ‘webserver’ and hence the logic breaks.

Using the ‘groups’ mechanism doesn’t work very well either, since when a group is undefined, the entire playbook fails. Working with many inventories that have different groups defined, this breaks the portability of my roles.

The only thing I can think of that would work but which is dead ugly, is defining a variable on group level that says ‘webserver_installed: true’ or similar, and have the agent role install the scripts when defined.

Is there any other approach that anyone can think of?

Thanks a lot,
Nico