我有以下磁盘迭代的清单
class my_module::filesystem {
include 'my_module::params'
my_module::recursion { 'start':
fssize => '0',
disk => $my_module::params::count,
}
}
include my_module::filesystem
下面是定义类,使用自定义函数进行迭代
define my_module::recursion($fssize,$disk) {
$app = inline_template("<%= fssize.to_i + 1 %>")
file { "/grid/0${app}" :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
my_module::recursion { "count+${app}":
fssize => $app,
disk => $disk,
}
}
当我运行清单时出现以下错误,
puppet apply -t --noop filesystem.pp
Info: Loading facts
Info: Loading facts
Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call,
Failed to parse inline template: undefined local variable or method `fssize' for #<Puppet::Parser::TemplateWrapper:0x0000000375d188> at
/etc/puppetlabs/code/environments/production/modules/my_module/manifests/recursion.pp:2
at /etc/puppetlabs/code/environments/production/modules/my_module/manifests/filesystem.pp:5 on node myserver.master.com
上述清单从 puppet 3.8 导入,目前正在 puppet 2015.3.1 中进行测试
我怀疑 puppet 2015 不支持“inline_template”
答案1
我认为您以错误的方式引用了该变量。
[0] % puppet --version
4.3.2
% puppet apply -e 'notice(inline_template("<%= $::fqdn =>"))'
Notice: Scope(Class[main]): nb.localnetwork.intra =>
Notice: Compiled catalog for nb.localnetwork.intra in environment production in 0.05 seconds
Notice: Applied catalog in 0.04 seconds
答案2
这是 inline_template 函数的问题。我将其更改为 inline_epp,我的测试用例通过了。