Chef infra 厨师根据bash命令输出返回菜谱
在Chef中有没有一种方法可以根据bash命令的输出返回菜谱 我尝试了以下方法:Chef infra 厨师根据bash命令输出返回菜谱,chef-infra,chef-recipe,Chef Infra,Chef Recipe,在Chef中有没有一种方法可以根据bash命令的输出返回菜谱 我尝试了以下方法: execute 'check_output' do command <<-EOH output=$(echo "hi") if [ "$output" == "hi" ]; then return 0 fi EOH end include_recipe 'blahblah::default' 执行“检查输出”do 命令实际上与您编写它的方式不同,因为在
execute 'check_output' do
command <<-EOH
output=$(echo "hi")
if [ "$output" == "hi" ]; then
return 0
fi
EOH
end
include_recipe 'blahblah::default'
执行“检查输出”do
命令实际上与您编写它的方式不同,因为在包含recipeblablablah::default
之后的收敛时间之前,不会考虑execute
资源的属性。您无法决定是否在收敛期间包含另一个配方
要做您想做的事情,您想做的任何shell内容都必须在编译时可确定,例如:
include_recipe'blahblah::default',除非'echo-n“hi”`='hi'
这将导致配方不包括在内
请参见coderanger对Chef双通道模型的详细描述:
要将其应用于您想要做的事情,您必须决定是否在编译时而不是在收敛时获取include\u recipe