是否可以从配置文件或角色覆盖清单/类排序? [英] is it possible to Override manifest/class ordering from a profile or role?

查看:48
本文介绍了是否可以从配置文件或角色覆盖清单/类排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个角色使用包含和链接按顺序调用多个配置文件:

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']
}

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

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.

这是我的詹金斯简介

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

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

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?

推荐答案

模块本身包含它自己的围绕其清单的锚定顺序,这似乎覆盖了我的角色 [...]这是我尝试使用角色时得到的错误 [循环依赖错误]

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.

有没有办法从我的角色中覆盖 jenkins 模块的排序?或者告诉木偶忽略它

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.

真正的问题似乎是您表达了不需要的约束,其中一些与其他地方表达的约束相冲突.请特别注意,需要一种物理资源到位才能有用,并不一定意味着需要在另一个之前管理.特别是,我不清楚为什么 role::buildserver 类需要表达任何它所做的顺序约束.

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.

为什么它尝试首先和最后运行 Jenkins?

Why does it try to run Jenkins first and last?

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

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.

对循环有贡献的一些顺序约束似乎来自 ::jenkins 类和你命名的配置文件类,你没有提供,所以我不能自信地提供特定的解决方案,但您应该寻找如何通过删除不需要的约束来打破循环.您可能需要在多个地方使用多个约束来执行此操作.

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.

这篇关于是否可以从配置文件或角色覆盖清单/类排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆