我fingreprint.txt
在位置"#{node['abc.d']}/fingreprint.txt"
如何分配的文件内容厨师节点属性
该文件的内容如下:
time="2015-03-25T17:53:12C" level=info msg="SHA1 Fingerprint=7F:D0:19:C5:80:42:66"
现在我想要检索指纹的价值和分配它厨师属性
我使用下面的红宝石块
ruby_block "retrieve_fingerprint" do
block do
path="#{node['abc.d']}/fingreprint.txt"
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
command = 'grep -Po '(?<=Fingerprint=)[^"]*' path '
command_out = shell_out(command)
node.default['fingerprint'] = command_out.stdout
end
action :create
end
它似乎并没有被工作因为在command = 'grep -Po '(?<=Fingerprint=)[^"]*' path '
中缺少转义字符。 请让我知道,如果有指定的文件内容节点属性
我从未使用Ohai Plugin。请建议如何将上述ruby_block转换为OHAI插件。也。与IO.read我得到编译错误,因为文件不存在,直到运行时间。 – meallhour
你知道Google的事吗? – StephenKing