添加带有 puppet 的 yum 存储库 - 服务器上的错误 400:在大括号中启用无效参数?

qua*_*nta 1 yum puppet repository

我正在尝试在接收新服务器时自动执行一些任务。第一件事是添加一些 yum 存储库。

我的/etc/puppet/modules/repo/manifests/init.pp

     1  class repo {
     2      file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL": 
     3          owner   => root, 
     4          group   => root, 
     5          mode    => 0644, 
     6          source  => "puppet:///repo/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL" 
     7      }
     8  
     9      yumrepo { 
    10          "epel":
    11              descr       => 'the epel repo',
    12              mirrorlist  => 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch',
    13              enable      => 1,
    14              gpgcheck    => 1,
    15              gpgkey      => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL", 
    16              require     => File["/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL"]
    17      }
    18  }
Run Code Online (Sandbox Code Playgroud)

使用puppet parser validate.

但是在连接 puppet 代理时出现以下错误:

# puppet agent --no-daemonize --verbose
notice: Starting Puppet client version 2.7.1
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter enable at /etc/puppet/modules/repo/manifests/init.pp:17 on node svr051-4170
notice: Using cached catalog
err: Could not retrieve catalog; skipping run
notice: Caught INT; calling stop
Run Code Online (Sandbox Code Playgroud)

如您所见,第 17 行是右大括号。我真的不明白问题是什么。任何帮助将不胜感激。

Han*_*an5 7

“启用”实际上不是yumrepo 资源的有效参数。它被称为“启用_d_”。

它在花括号上窒息的原因是它是该部分的结尾。我不知道 Puppet 解析文件的具体细节,但我的猜测是 Puppet 在解析过程中抓取了所有参数并一起处理,所以直到解析器离开该部分时它才知道有问题。