Apache and multiple vhosts including their dependencies.

Hi,

I’ve built a very generic Apache role that can set up a bunch of vhosts, however I’m running into a design problem.

Each vhost has a dependency, for example ‘subversion’ requires a bunch of packages and a repository to be created (subversion specific tasks), the same goes for all the other vhosts.
Running the ‘apache’ role and passing in my vhosts structure will set up the vhosts but not the dependencies, so I was trying to reverse the behavior i.e. setting up subversion will setup apache through a role dependency which works fine, the only downside is that certain tasks in the apache role get executed over and over again even though I just want to add a ‘vhost’ at that point.

Options I see:

  1. Create a separate role ‘apache-vhosts’ to take care of setting up vhosts
  2. Pass in a list of all vhosts to the apache role at once after setting up all “dependencies”

Point 2 seems the most elegant to me, however then I run into the problem of “collecting” the variables of all these roles.
I’m clearly struggling with this, does anybody have some design advice on how best to approach this?

Just to make it clear, I do want the roles to “know” about each other, running apache with “setup these vhosts” and then running the roles to setup the content seems a bit silly to me, as those content roles could set the document root (install dir) etc. etc.

Thanks guys.

Nico