[英]Puppet module use
是的,我一直在使用Puppet。 4個小時,總共有n000b個問題。 我已經使用以下方法下載並安裝了一個人偶模塊:
puppet module install resolv_conf
一切都很好。 它已將模塊安裝到:
/home/user/.puppet/modules/
,一切都很好。
當我運行puppet module list
,該模塊就會顯示出來,我猜應該是這樣。
所以我的問題是如何使用該模塊?
我知道需要添加到清單中的地方,
class { 'resolv_conf': nameservers => ['192.168.0.254', '8.8.8.8'], }
但我假設我不會在
/home/user/.puppet/modules/resolv_conf/manifests/init.pp
文件。
我嘗試在此處創建文件夾和init.pp文件
/etc/puppet/modules/resolv_conf/manifests
並添加了課程,但我得到了
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class resolv_conf at /etc/puppet/modules/resolv_conf/manifests/init.pp:4 on node rarity.home
所以我有點困惑。 某種善良的靈魂可以將我指向正確的方向嗎?
Fanks :)
因此,默認情況下, puppet module
命令會將模塊下載到本地目錄中。
假設您的主服務器正常運行,則需要將模塊安裝到$modulepath
,您可以通過執行以下操作在主$modulepath
上找到$modulepath
:
puppet config print modulepath
哪一個取決於您的Puppet版本(我正在運行v4,所以如果您使用v3,則可能會略有不同),則會返回以下內容:
/etc/puppetlabs/code/environments/production/vendor:/etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules
使用Puppet Module命令將模塊安裝到這些目錄之一中,如下所示:
puppet module install -i /etc/puppetlabs/code/modules
現在,您的主人將理解並能夠讀取resolv_conf
模塊,但是您需要將其應用於節點。 為此,您需要設置節點定義
在您之一,所以$modulepaths
你需要有一個目錄manifests
包含一個清單, site.pp
這就是所謂的“ 主清單 ”
在其中,為您的代理創建一個節點定義,類似於示例中的定義:
node 'www1.example.com' {
include resolv_conf
}
這是您可以進行的最簡單的設置。 一些進一步的閱讀:
祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.