尽管 not_if 命令退出 2,但已跳过 Chef 资源
Chef resource skipped even though not_if command exits 2
该资源有一个 not_if 守卫,我已验证命令的退出代码不为零。然而厨师 运行 的输出显示由于 not_if.
而跳过了资源
资源看起来像
device_id = "/dev/xvdf"
execute 'yes | mkfs -t ext4 #{device_id}' do
not_if 'blkid -o value -s TYPE #{device_id} && blkid -o value -s TYPE #{device_id} | grep ext4'
timeout 1200
end
唉。 Ruby 不插入单引号字符串。将它们更改为双引号并解决了问题。
该资源有一个 not_if 守卫,我已验证命令的退出代码不为零。然而厨师 运行 的输出显示由于 not_if.
而跳过了资源资源看起来像
device_id = "/dev/xvdf"
execute 'yes | mkfs -t ext4 #{device_id}' do
not_if 'blkid -o value -s TYPE #{device_id} && blkid -o value -s TYPE #{device_id} | grep ext4'
timeout 1200
end
唉。 Ruby 不插入单引号字符串。将它们更改为双引号并解决了问题。