我在我定義的類型remote_file
中定義了一些變量。木偶在需求中定義兩個變量,但一個變量不起作用
當我在class cdnlog::base
實例化這個類型,如果我評論了符合require_dir
,我在木偶客戶得到一些錯誤信息:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: File[cdnlog-release] { require => , }, because , doesn't seem to be in the correct format. Resource references should be formatted as: Classname['title'] or Modulename::Classname['title'] (take careful note of the capitalization).
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
我的清單:
define remote_file($remote_location=undef, $path=undef, $mode='0644', $require_dir=undef){
exec{"retrieve_${title}":
command => "/usr/bin/wget -q ${remote_location} -O ${path}",
creates => $path,
}
$require_exec="Exec[retrieve_${title}]"
if $require_dir {
$require_file="File[$require_dir]"
}
elsif $require_dir == undef {
$require_file=","
}
file{$title:
path => $path,
mode => $mode,
require => [$require_exec, $require_file],
}
}
class cdnlog::base{
tag 'cdnlog'
file {'/etc':
ensure => directory,
recurse => true,
}
file {'/etc/rc.d/init.d':
ensure => directory,
recurse => true,
}
file {'/etc/cdnlog.d':
ensure => directory,
recurse => true,
}
###########################################
###########################################
###########################################
remote_file {'cdnlog-release':
path => '/etc/cdnlog.d/cdnlog-release',
remote_location => "${collectd_server}/tarball/cdnlog-release",
require_dir => '/etc/cdnlog.d',
}
remote_file {'cdnlog.conf':
path => '/etc/cdnlog.conf',
remote_location => "${collectd_server}/tarball/cdnlog.conf",
require_dir => '/etc',
}
}
感謝您的幫助
這是正確的答案。@ Raul Andres非常感謝你 – bertramlau 2014-09-04 08:21:31