我有一个非常恼人的错误,我急于弥补。我有一个木偶模块,其中某些东西保存在yaml文件(hiera)中,这样人们就可以快速地编辑该部分。
结构是嵌套的。
这样的模板:
<%= @platforms[@platform]['users_allowed'][@host].class %>呈现如下:
Array但是当我试图迭代它时:
<% @platforms[@platform]['users_allowed'][@host].each do | pubkey | %>
<%= pubkey %>
<% end %>木偶说:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template somemodule/templates/authorized_keys.erb:
Filepath: /etc/puppet/modules/somemodule/templates/authorized_keys.erb
Line: 1
Detail: undefined method `each' for nil:NilClass它怎么会突然变成零,我怎么在这里迭代呢?
恐怕我被困在这里了,甚至不知道我应该往哪个方向去寻找解决方案。
在这种情况下,没有hiera或没有嵌套结构的重写模块不是一个选项。
发布于 2014-02-21 18:20:00
我对我的木偶进行了测试,正确的语法是:
<% @platforms[@platform]['users_allowed'][@host].each do | pubkey | -%>
<%= pubkey %>
<% end -%>希望我能帮上忙。
https://serverfault.com/questions/577326
复制相似问题