【发布时间】:2016-07-06 06:32:41
【问题描述】:
我正在尝试调用 ruby_block 中的 Chef 资源。谁能告诉我这段代码有什么问题?
file '/tmp/arockia/storage.txt' do
end
lines = `cat /tmp/arockia/storage.txt | wc -l`
ruby_block 'Check for content' do
block do
lines = `cat /tmp/arockia/storage.txt | wc -l`
if Integer(lines) == 0
r = Chef::Resource::Execute.new('Get-Disk-Storage',run_context)
r.command 'df -kh >> /tmp/arockia/storage.txt'
r.run_action :run
end
end
end
【问题讨论】:
-
什么不工作/错误信息?
-
@StephenKing 没有错误。它说“执行红宝石块检查内容”
-
您是否尝试过将其简化为最小示例,即删除
if条件? -
它与资源一起工作(:execute => "Get-Disk-Storage").run_action(:run)
标签: ruby chef-infra