我得到的模板错误是由于backend.key=<%= node['key']%
>源key.properties.erb
>在运行shellout时没有值。无法在运行时设置节点属性,并将其引用到厨师模板中
Error : Chef::Mixin::Template::TemplateError - undefined method `[]' for nil:NilClass
我有一个红宝石块获取文件cat /tmp/key.txt
和节点值分配的输出。
红宝石块:
ruby_block "Get_key" do
block do
#tricky way to load this Chef::Mixin::ShellOut utilities
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
command = 'cat /tmp/key.txt'
command_out = shell_out(command)
node.set['key'] = command_out.stdout
end
action :create
end
厄尔布:
backend.key=<%= node['key']%>
我做的一个非常类似的事情[这里](https://github.com/TYPO3-cookbooks/gerrit/blob/fc82b9d82663f040116aed62bdcc3991e858ab98/recipes/peer_keys.rb) – StephenKing