Templates 如何使用未来解析器在木偶模板中包含子模板
在我们从Puppet 3.5.7升级到Puppet 3.5.7的过程中,以及将以下信息拼接在一起之后: 我可以引用文件名中带有某个变量的子模板,如下所示:Templates 如何使用未来解析器在木偶模板中包含子模板,templates,puppet,upgrade,erb,Templates,Puppet,Upgrade,Erb,在我们从Puppet 3.5.7升级到Puppet 3.5.7的过程中,以及将以下信息拼接在一起之后: 我可以引用文件名中带有某个变量的子模板,如下所示: <%= scope.function_template([File.dirname(__FILE__) + "/" + "subtemplate_" + @oscar_package + ".properties.erb"]) %> 启用future解析器后,出现以下错误: 错误:无法从远程服务器检索目录:上的错误400
<%= scope.function_template([File.dirname(__FILE__) + "/" + "subtemplate_" + @oscar_package + ".properties.erb"]) %>
启用future解析器后,出现以下错误:
错误:无法从远程服务器检索目录:上的错误400
服务器:求值错误:求值函数调用时出错,
无法分析模板
oscar\u mysql\u tomcat/context/oscar\u demo15.properties.e rb:文件路径:org/jruby/RubyString.java 行:1172
详细信息:无法将nil转换为字符串 at/etc/puppet/environments/development/modules/oscar\u mysql\u tomcat/manifests/context.pp:11:18 在节点bcmdit-devel-536-puppetclient上警告:未在上使用缓存 失败的目录错误:无法检索目录;跳绳跑 @oscar_包的解析失败了,我以后怎么做 更新1 咨询后: 似乎我应该使用scope.call\u函数:
<%= scope.call_function('template', [File.dirname(__FILE__) + "/" + "subtemplate_" + @oscar_package + ".properties.erb"]) %>
这会产生相同的错误。我使用的类是另一个定义了oscar_package变量的类的子类 通过将变量传递给子类来解决这个问题,这样就可以在调用erb模板中的函数的范围内直接访问它 因此,在init.pp定义中,相关代码是:
if $sys_report::active_database_context_list != "" {
oscar_mysql_tomcat::context { "active_${sys_report::active_database_context_list}":
db_name => "$sys_report::active_database_context_list",
oscar_package => "$oscar_package",
oscar_package_build => "$oscar_package_build",
role => "link",
tomcat_site_seal => "$tomcat_site_seal",
tomcat_host_fqdn => "$tomcat_host_fqdn",
tomcat_port => "$tomcat_port",
twitter_feed => "$twitter_feed",
require => File['/etc/sys-report.var'],
}
}
您提到了未来的解析器,所以这就是您当前使用的Puppet 3.x?这是非常过时的,因此升级可能是这里的第一步,如果它是一个选项的话。@MattSchuchard我正在升级Puppet,部分过程是切换到使用未来的解析器为Puppet4做准备,以找到需要更改代码的地方。好;因此,由于在Ruby中将
@oscar_package
实例化为nil
,因此从Puppet函数调用到模板的绑定出现了一些问题。这意味着问题最有可能出现在清单代码中。“我们能看看这其中的相关部分吗?”马特舒查德谢谢,这让我走上了正确的道路。