问题
I have a role that calls several profiles in order using contains and chaining like this:
class role::buildserver {
contain ::profile::<all the classes below>
Class['::profile::chocolatey'] ->
Class['::profile::jdk'] ->
Class['::profile::googlechrome'] ->
Class['::profile::jenkins_install']
}
The chain works fine until I include the jenkins_install profile which uses the jenkins module. No matter what I do the jenkins module always gets called first. The module itself contains it's own anchoring order around it's manifests which seems to override my role. Is there a way to override the jenkins module ordering from my role? or tell puppet to ignore it.
This is my jenkins profile
class profile::jenkins_install (
$somevariables
)
class{ '::jenkins':
configure_firewall => false,
cli => true,
plugin_hash => $plugin_hash,
}
contain ::jenkins
}
This is the error I get when trying to use the role:
(Anchor[jenkins::begin] => Class[Jenkins::Package] => Package[jenkins] => Class[Jenkins::Package] => Class[Jenkins::Config] => Class[Jenkins::Config] => Class[Jenkins::Plugins] => Jenkins::Windows::Plugin[jenkinswalldisplay] =>
Download_file[jenkinswalldisplay.hpi] => Class[Profile::Specflow] => Package[specflow] => Class[Profile::Specflow] => Class[Profile::Tortoisesvn] => Package[tortoisesvn] => Class[Profile::Tortoisesvn] => Class[Profile::Googlechrome] => Package[GoogleChrome] => Class[Profile::Googlechrome] =>
Class[Profile::Jenkins_install] => Class[Jenkins] => Anchor[jenkins::begin])
Why does it try to run Jenkins first and last?! I can only think it is the puppet-labs jenkins module using anchor that is causing this. Is there a way to override their ordering?
回答1:
The module itself contains it's own anchoring order around it's manifests which seems to override my role [...] This is the error I get when trying to use the role [cyclic dependency error]
So in fact the problem is that the class you are including does not override any order-of-application constraints declared elsewhere.
Is there a way to override the jenkins module ordering from my role? or tell puppet to ignore it
No, and it does not make sense to do so. If the order-of-application constraints you have expressed are genuine and appropriate, then having other resources under management as well cannot invalidate them.
The true problem seems to be that you are expressing unneeded constraints, and some of those conflict with constraints expressed elsewhere. Note in particular that needing to have one physical resource in place in order for another to be useful does not necessarily mean that one needs to be managed before the other. In particular, it is not obvious to me why class role::buildserver
needs to express any of the order constraints it does.
Why does it try to run Jenkins first and last?
It doesn't. The message excerpt depicts how the order-of-application requirements you have placed form a cycle. It could express that cycle equivalently with any resource in it as start and end points. Puppet doesn't apply any of the resources participating in the cycle, because it cannot simultaneously satisfy all the order-of-application constraints.
Some of the order constraints that contribute to the cycle appear to come from class ::jenkins
and from the profile classes you have named, none of which you have presented, so I cannot confidently offer a specific solution, but you should look for how to break the cycle by removing unneeded constraints. It may be that you need to do this with several constraints, in several places.
来源:https://stackoverflow.com/questions/33631312/is-it-possible-to-override-manifest-class-ordering-from-a-profile-or-role