2017-05-04 58 views
1

我在主 - >代理模型中使用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 

+1

你必須設置標籤在類的作品前。 –

+0

就是這樣;你能回答這個問題嗎 ?這樣我可以標記它的答案。 – bubbly

回答

1

您可以使用--tags參數執行資源子集,就像您在問題中提到的一樣。但是,首先必須在要爲該標記執行的資源中設置關聯的標記。如果您只想執行一個類,則可以爲該類設置一個標記,並將該標記指定爲參數--tags以僅執行該類。

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

在這種情況下,標籤功能會比metaparameter對您有用得多。

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