我有用hiera编写的现有puppet模块。基本上,数据模块有param.pp模式。木偶3.x中的一切都很好。但是在使用puppet 4.x设置并运行puppet代理后,跟随错误返回哈希键。
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Failed to parse template wso2ei/conf/carbon.xml.erb:
Filepath: /etc/puppetlabs/code/environments/production/modules/wso2ei/templates/conf/carbon.xml.erb
Line: 138
Detail: undefined method `[]' for nil:NilClass
at /etc/puppetlabs/code/environments/production/modules/wso2base/manifests/push_templates.pp:23:16 at /etc/puppetlabs/code/environments/production/modules/wso2base/manifests/configure.pp:59 on node puppet4-aa54a7f2-83a6-43d2-b8d7-c15a42591e88.openstacklocal
carbon.xml.erb的特定部分如下所示
<%- if @ports['offset'] -%>
<Offset><%= @ports['offset'] %></Offset>
<%- else -%>
<Offset>0</Offset>
<%- end -%>
hieradata在yaml文件中设置如下
wso2::ports:
offset: 0
写param.pp来读取数据
$ports = hiera('wso2::ports')
init.pp设置值如下
$ports = $wso2ei::params::ports,
模板不会为单个行数据提供任何错误。有关carbon.xml.erb中的示例
<% if @hostname %>
<HostName><%= @hostname %></HostName>
<%- else -%>
<!--HostName>www.wso2.org</HostName-->
<% end %>
yaml文件中的hieradata
wso2::hostname: "%{::fqdn}"
所有哈希键都会出现相同的错误。当我谷歌时,发现@
必须替换为scope
,如下所示。但是有很多地方需要改变。
<%- if scope['wso2ei::params::ports']['offset'] -%>
<Offset><%= scope['wso2ei::params::ports']['offset'] %></Offset>
<%- else -%>
<Offset>0</Offset>
<%- end -%>
有没有办法在puppet 4中保留现有的param.pp数据模块模式?感谢您的帮助。