I am trying to solve the following problem with Puppet:
I have several nodes. Each node includes a set of classes. For example, there is a class mysqland webserver. node1 is only a web server, node2 is webserver + mysql.
I want to point out that IF a node has both webserver and mysql, mysql will install before the web server.
I cannot have a dependency Class[mysql] -> Class[webserver], since MySQL support is optional.
I tried using the steps, but they seem to inject dependencies between my classes, so if I have, for example, this:
Stage[db] -> Stage[web]
class {
'webserver':
stage => web ;
'mysql':
stage => db ;
}
and I include the webserver class in my node
node node1 {
include webserver
}
.. the mysql class is also included! This is not what I want.
How to determine the order on additional classes?
Edit: here is the solution:
class one {
notify{'one':}
}
class two {
notify{'two':}
}
stage { 'pre': }
Stage['pre'] -> Stage['main']
class {
one: stage=>pre;
}
if defined(Class['two']) {
class {
two: stage=>main;
}
}
node default {
include one
}
Result:
notice: one
notice: /Stage[pre]/One/Notify[one]/message: defined 'message' as 'one'
notice: Finished catalog run in 0.04 seconds
~