是否可以从配置文件或角色覆盖 manifest/class 排序?

is it possible to Override manifest/class ordering from a profile or role?

我有一个角色可以调用多个配置文件,以便使用包含和链接,如下所示:

class role::buildserver {
  contain ::profile::<all the classes below>
  Class['::profile::chocolatey'] ->
  Class['::profile::jdk'] ->
  Class['::profile::googlechrome'] ->
  Class['::profile::jenkins_install']
}

链工作正常,直到我包含使用 jenkins 模块的 jenkins_install 配置文件。无论我做什么,jenkins 模块总是首先被调用。该模块本身包含它自己的围绕它的清单的锚定顺序,这似乎超越了我的角色。有没有办法覆盖我角色的 jenkins 模块排序?或者让 Puppet 忽略它。

这是我的詹金斯个人资料

class profile::jenkins_install ( 
  $somevariables
)
  class{ '::jenkins':
    configure_firewall => false,
    cli                         => true,  
    plugin_hash           => $plugin_hash,
  } 
contain ::jenkins
}

这是我在尝试使用角色时遇到的错误:

(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])

为什么它首先和最后尝试 运行 Jenkins?!我只能认为是使用 anchor 的 puppet-labs jenkins 模块导致了这个问题。有没有办法覆盖他们的顺序?

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]

所以实际上问题是 class 您包括的 不会 覆盖其他地方声明的任何应用顺序约束。

Is there a way to override the jenkins module ordering from my role? or tell puppet to ignore it

不,这样做没有意义。如果您表达的应用程序顺序限制是真实和适当的,那么将其他资源也置于管理之下并不能使它们无效。

真正的问题似乎是您表达了不需要的约束,并且其中一些与其他地方表达的约束冲突。请特别注意,需要有一种物理资源才能使另一种物理资源 有用 并不一定意味着需要先 管理 另一个。特别是,我不明白为什么 class role::buildserver 需要表达 any 它所做的顺序约束。

Why does it try to run Jenkins first and last?

没有。消息摘录描述了您放置的应用程序顺序要求如何形成一个循环。它可以用其中的任何资源作为起点和终点来等效地表示该循环。 Puppet 不应用任何参与循环的资源,因为它不能同时满足所有应用顺序约束。

一些导致循环的顺序限制似乎来自 class ::jenkins 和您命名的配置文件 classes,其中 none你已经提出了,所以我不能自信地提供一个具体的解决方案,但你应该寻找如何通过消除不必要的约束来打破循环。可能您需要在几个地方使用多个约束来执行此操作。