如何使用 Puppet 正确安装存储库

如何使用 Puppet 正确安装存储库

我正在努力使用 Puppet 安装存储库,特别是 zabbix 存储库。我从以下位置获取了适用于 CentOS 7 的 zabbix 存储库这里,并使用以下内容:

http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

我尝试使用以下 Puppet 代码将其安装在我的节点上,但似乎不起作用:

node 'puppet-agent' {
    include importRepos
    package { 'php':
        ensure => "installed",
    }
    package { 'zabbix-agent':
        ensure => "installed", 
    }

}

class importRepos {
    yumrepo { "zabbix":
        baseurl => "http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm",
        descr => "Zabbix repo to install Zabbix client on CentOS 7",
        enabled => 1,
        gpgcheck => 1
        }
}

我得到的错误是:

...
Execution of '/usr/bin/yum -d 0 -e 0 -y install zabbix-agent' returned 1: Delta RPMs disabled because /usr/bin/applydeltarpm not installed.


Error downloading packages:
  zabbix-agent-3.4.15-1.el7.x86_64: [Errno 256] No more mirrors to try.

我尝试安装 deltarpm 包,现在出现此错误:

...
Error downloading packages:
  zabbix-agent-3.4.15-1.el7.x86_64: [Errno 256] No more mirrors to try.
Error: /Stage[main]/Main/Node[puppet-agent]/Package[zabbix-agent]/ensure: change from purged to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install zabbix-agent' returned 1: No Presto metadata available for zabbix


Error downloading packages:
  zabbix-agent-3.4.15-1.el7.x86_64: [Errno 256] No more mirrors to try.

然后我做了并yum clean all再次尝试,现在我收到此错误:

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install zabbix-agent' returned 1: One of the configured repositories failed (Zabbix repo to install Zabbix client on CentOS 7),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

它建议我禁用 repo,所以我不确定我犯了什么错误,但是出于某种原因,根据我的配置方式,repo 似乎无效。有谁知道如何让 zabbix repo 在 Puppet 中工作,以便我可以安装 zabbix 代理?

答案1

事实证明我的想法是错误的。我只需安装包并指定 RPM 作为源,它就可以工作。我测试了以下代码,它有效:

package { 'zabbix-release':
  ensure => 'installed',
  source => 'http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm',
  provider => 'rpm'
}

这将为我安装 RPM,然后我可以从那里安装 zabbix-agent。

相关内容