簡體   English   中英

在節點默認值中使用 class 運行 Puppet Agent 時出錯

[英]Error while running Puppet Agent using class in node default

執行 puppet腳本時出現錯誤

在 Puppet master site.pp文件上,我編寫了以下代碼

node default {
  class t {
    package {'apache2':
      ensure => installed,
    }
  }
}

在從機器上,當我使用puppet agent --test執行它時,它會拋出錯誤:

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not parse for environment production: Classes, definitions, and nodes may only appear at toplevel or inside other classes (file: /etc/puppet/code/environments/production/manifests/site.pp, line: 3, column: 1) on node slave.ec2.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

你能在這方面幫助我嗎

嗨,這是因為您不應該在site.pp中定義類

有一個模塊foo (因為我更喜歡foo作為示例而不是t )定義如下:

#modules/foo/manifests/init.pp
class foo {
  package {'apache2':
      ensure => installed,
  }
}

並且您的 site.pp 中有一個節點條目,如下所示

# site.pp
node default {
  include 'foo'
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM