Puppet

將 Puppet 程式碼遷移到 Puppet 4:類問題

  • July 20, 2016

我們正在將我們的 Puppet Code 從遷移3.5.74.5.2

應用清單時出現以下錯誤

 Error: Failed to apply catalog: Parameter unless failed on Exec[sh /home/agile/svncheckout.sh]: 'test -f /home/agile/subversion.done' is not qualified and no path was specified. Please qualify the command or specify a path. at /apps/wps/puppetlabs/code/environments/production/manifests/classes/subversion.pp:17

主要程式碼如下:

node 'Node-002' {
include user_default
include standard
include subversion
# include java
include sybase
# include eclipse
# include oxygen
$fqdn="Node-002.wiley.com"

file { "/home/agile/properties":
  ensure => present,
  owner => agile,
  group => agile,
  source => "puppet://puppet/templates/${fqdn}/properties",
 }

  file { "/home/agile/.bashrc":
   ensure => present,
   owner => agile,
   group => agile,
   source => "puppet://puppet/files/.bashrc",
   require => Class['sybase'],
 }

file { "/home/agile/setup_firefox3v622.sh":
   ensure => present,
    owner => agile,
    mode => "755",
    require => Class['subversion'],
    source => "puppet://puppet/scripts/setup_firefox3v622.sh
   }
 }

subversion.pp如下

 class subversion {
   package {'subversion':
   ensure => installed,
 }

file {'/home/agile/svncheckout.sh':
 ensure => present,
 group => agile,
 mode => "755",
 source => "puppet://puppet/scripts/svncheckout.sh",
 require => [ Package['subversion'], Class['user_default'] ],
 before => [Class['apache1'], Class['sybase']],
} 
exec { "sh /home/agile/svncheckout.sh":
 user => agile,
 timeout => 0,
 logoutput => true,
 #path => "/usr/sbin:/usr/bin:/bin",
 require => [ Package['subversion'], Class['user_default'], File['/home/agile/svncheckout.sh'] ],
 before => [ Class['apache1'],  Class['sybase'] ],
 unless => "test -f /home/agile/subversion.done",
}

}

看起來svncheckout.sh沒有被複製到/home/agile/svncheckout.sh位置。

puppet.conf中的程式碼配置如下:codedir = /app/zama/puppetlabs/code

基於此,我按照參數中的scripts,files and templates定義復製source到以下位置

  $ls
 environments  files  modules  scripts templates
  $pwd
  /app/zama/puppetlabs/code

source我想我不確定根據上面的清單將文件放在哪裡。

您尚未包含所有 subversion.pp,但看起來您具有以下內容:

exec { 'sh /home/agile/svncheckout.sh':
 unless => 'test -f /home/agile/subversion.done',
 ...
}

錯誤是test命令不合格。將其更改為/bin/test或添加path => ...包含/bin或任何位置的參數test

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