Ubuntu

使用 Puppet apt 模組

  • February 26, 2015

我是 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

知道我在模組中做錯了什麼嗎?

您需要include apt在類的頂部,在apt::source聲明之前添加:錯誤是說它找不到apt::things,因為它不知道更高的範圍apt是什麼。

include apt使用各種預設值,如果要更改它們,則需要使用如下聲明:

class { 'apt':
   always_apt_update => true,
}

…例如。鍛造頁面上的更多資訊。

另外,您的要求是錯誤的:您還需要指定名稱,所以我認為它應該Apt::Source['newrelic']代替Class['apt::source'].

引用自:https://serverfault.com/questions/671606