I'm an absolute beginner at Puppet, and I'm having an issue when I try to install a package via the 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'],
}
}
This is the error I receive:
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
Any idea what I'm doing wrong in my module?
You need to add
include apt
at the top of your class, before theapt::source
declaration: the error is saying it can't findapt::things
because it doesn't know what the higher scopeapt
is.The
include apt
will use various defaults, if you want to change them you'll need to instead use a declaration such as:...for example. More info on the forge page.
Also, your require is wrong: you need to specify the name as well, so I think it should be
Apt::Source['newrelic']
instead ofClass['apt::source']
.