Puppet will contain all defined types declared inside another defined type (or class). As far as I understand, this implies that any declared source will depend on the container. This will result in a dependency loop:
define user {
}
define bar {
user { $name: }
->
Bar[$name]
}
bar { 'foo': }
Error: Could not apply complete catalog: Found 1 dependency cycle: (User[foo] => Bar[foo] => User[foo])
Is there any way to avoid this? I ahve one specific instance where I would prefer that when Bar[$name] is declared, User[$name] be declared as well, but have Bar[$name] depend on User[$name], not the other way around. Basically the same behavior as require, but for a defined type dependency.
Is there any way to accomplish this or is the only solution to have the manifest declaring Bar[$name] declare User[$name] as well (and then add the dependency on either the body of bar or in the declaring manifest?
A more realistic example:
define servize {}
define appserver {
user { $name: }
->
servize { $name: }
}
appserver { 'app': }
# the deploy application needs a directory owned by itself on startup
file { '/tmp/foobar':
ensure => directory,
owner => 'app', # auto-require
}
->
Appserver['app']
User[$name]is declared byBar[$name], so what you really need is to have all resources declared byBar[$name]that are notUser[$name]to depend onUser[$name], correct? Would it not be straight forward to express just that? - Felix Frankuseronappserveris still a problem. My example is a bit simplistic. Check my edit. In this case, you could break the loop by adding the dependency onServizeinstead (and further break the abstraction...) but in more complex scenarios I sometimes still get loops from the service dependencies. It's simply unnecessary and undesirable to haveuserdependappserver. I wish that was a variant ofcreate/ensure_resourcesthat would create the resources and have them float in the graph (like classes). - Artefacto