How to set up cluster that has dependencies?

Chef folks,

I have a question concerning the best way to use Chef to set up a cluster of
nodes that have dependencies on one another. (Apologies in advance if this is a
naïve question, but I’m new to Chef.)

For concreteness, suppose I want node V to run varnish, node T to run tomcat,
and node M to run mongo. And let’s say that T needs to know the IP address
of M, and V needs to know the IP address of T. I believe that each node can
register its IP address in a database maintained on the Chef server, and
recipes run by each node can query this database. For things to work properly,
I ought to set up M first, then T, and finally V.

My question is this: How I should plan to use Chef so that the setup of various
nodes happens in the right order? Do I write a recipe that sets up M first,
then T, and finally V? If so, then what is that recipe associated to? Or
should I instead have a recipe for V that sets up T, and also have the setup
recipe for T begin by setting up M? Or should I write recipes for T, M, and V
that query the database, and don’t do anything unless they can find the IP
addresses they need?