Puppet:如何执行单个类?

时间:2017-05-04 16:08:11

标签: puppet

我在主人中使用Puppet - >代理模型。我的清单存储在主服务器上,作为快速测试,我在代理上执行puppet agent -t以触发Puppet运行。

随着时间的推移,我的清单变得非常大,我正在寻找只执行一个课程的能力mycompany.someclass.class

我尝试了一些基于谷歌搜索的变体,但没有一个有效

puppet agent --tags mycompany.someclass.class
puppet agent --tags "mycompany.someclass.class"

puppet agent --tags Mycompany.Someclass.Class
puppet agent -t --tags "Mycompany.Someclass.Class"

puppet agent -t --tags Mycompany.Someclass.Class
puppet agent --tags Mycompany.Someclass.Class

puppet apply --tags mycompany.someclass.class
puppet apply --tags Mycompany.Someclass.Class

2 个答案:

答案 0 :(得分:2)

您可以使用--tags参数执行资源子集,就像您在问题中提到的那样。但是,您首先必须在要为该标记执行的资源中设置关联标记。如果只想执行一个类,则可以为该类设置标记,并将该标记指定为--tags的参数,以仅执行该类。

https://docs.puppet.com/puppet/4.10/lang_tags.html

在这种情况下,标签功能对你来说比元参数更有用。

https://docs.puppet.com/puppet/4.10/lang_tags.html#the-tag-function

# You can use the tag function inside a class definition or defined type to assign tags to the surrounding container and all of the resources it contains
class myClass {
  tag 'mytag'
  ...
}

然后,您只能执行myClass

# execute agent with tags
puppet agent -t --tags mytag

https://docs.puppet.com/puppet/4.10/lang_tags.html#restricting-catalog-runs

答案 1 :(得分:0)

如果您不想标记所有资源,也可以使用类名称作为标记来运行代理。

为统一单位提供注意事项:这不是一张免监狱的卡,即使您仅应用了其中一些,有关该节点的所有类仍必须干净地编译。

相关问题