execute role dependencies _after_ role

As it currently stands, role dependencies are executed prior to the
role in which they are defined. This is a good feature.

But!

I'm running into the situation where I have a 'common' role that gets
run after some OS-specific roles -- mainly the OS-specific roles are
doing the package installation and OS specific configurations and the
common role is doing everything that is similar between the
distributions.

It would be great if I could tell the os-specific role to depend on
the common role, but make the common role execute _after_ the
os-specific role. Does this idea make sense? Would it be a useful
feature for others? Or should it be solved in a different way with
re-organizing my roles?

My current implementation just runs the roles in a specific order --
without any dependencies. It works, just wanted to see if there was a
way to clean things up.

- James

So basically requires: would have a requires_after: or similar?

Can you give an example of the role names so I can better get a feel for the use case?

Thanks!!!

Michael,

requires_after sounds like a good name.

Here's the way I have my roles structured:

riak/
  common/
  ubuntu/
  redhat/

I have a group_by task that runs in a bootstrap role and gives me
groups based on OS.

Then I apply riak/redhat which should depend on riak/common running
_afterwards_.

- James

That’d be a very useful feature! Currently, it’s possible to declare what roles roleA depends on. But sometimes, when writing isolated modules that constitute to a whole, one would like to express that roleA should depend on roleB and roleC when declaring those. Something named like required_by, required_in, required_before (note that we would like both roleB and roleC to be played before roleA). I think that name required_after would rather refer to a list of roles that should run before the role the name has been declared in, effectively being a synonym for dependencies.

" think that name required_after would rather refer to a list of roles that should run before the role the name has been declared in"

after should run before might be a bit confusing :slight_smile:

Hello.
Is any news about this problem ?

Hello! I know this thread is old but I am interested and I just got an idea on which I would like your opinion.

In my case, I have a “nginx/proxy” role that creates subdomains proxies to services on my server. I also have a “compose” role that manages those services.
The “nginx/proxy” gets the list of proxy configs from a variable that is updated by “compose”, which in the present case requires me to explicitly make “compose” run before “nginx/proxy”.

What if I want to use dependencies? I thought that I could separate “compose” in two parts: “compose/services” would manage the services and “compose/proxy” would only update the proxy list. Then I could write that “nginx/proxy” depends on “compose/proxy”.

I do not know if it is clear, if it is really relevant, and if such a workaround actually makes sense and would be usable.

Thank you for your comments :slight_smile: