我是 Puppet 的初学者,当我尝试通过 apt-module 安装包时遇到了问题。
class newrelic {
apt::source {
'newrelic':location => 'http://apt.newrelic.com/debian/',
repos => 'non-free',
key => '548C16BF',
key_source => 'https://download.newrelic.com/548C16BF.gpg',
include_src => false,
release => 'newrelic',
}
package {
'newrelic-sysmond':ensure => 'present',
notify => Service['newrelic-sysmond'],
require => Class['apt::source'],
}
service {
'newrelic-sysmond':ensure => 'running',
enable => true,
hasrestart => true,
hasstatus => true,
require => Exec['newrelic_config'],
}
exec {
'newrelic_config':path => '/bin:/usr/bin',
command => "/usr/sbin/nrsysmond-config --set license_key=xxxxxxx",
user => 'root',
group => 'root',
require => Package['newrelic-sysmond'],
notify => Service['newrelic-sysmond'],
}
}
这是我收到的错误:
Warning: Scope(Class[Apt::Update]): Could not look up qualified variable '::apt::always_apt_update'; class ::apt has not been evaluated
Warning: Scope(Class[Apt::Update]): Could not look up qualified variable 'apt::update_timeout'; class apt has not been evaluated
Warning: Scope(Class[Apt::Update]): Could not look up qualified variable 'apt::update_tries'; class apt has not been evaluated
Notice: Compiled catalog for host.domain.local in environment production in 0.33 seconds
Error: Could not find dependency Class[Apt::Source] for Package[newrelic-sysmond] at /home/jeroen/puppet/modules/newrelic/manifests/init.pp:16
知道我在我的模块中做错了什么吗?
答案1
您需要include apt
在类的顶部、apt::source
声明之前添加:错误表明找不到它,apt::things
因为它不知道更高的范围apt
是什么。
将include apt
使用各种默认值,如果您想更改它们,则需要使用如下声明:
class { 'apt':
always_apt_update => true,
}
...例如。更多信息请见伪造页面。
此外,您的要求是错误的:您还需要指定名称,所以我认为它应该是Apt::Source['newrelic']
而不是Class['apt::source']
。