在厨师中嵌套自定义资源

问题描述 投票:0回答:1

我正在尝试构建一个自定义资源,该自定义资源又将使用我的另一个自定义资源作为其操作的一部分。伪代码看起来像这样

customResource A
property component_id String

action: doSomething do
| if component_id is nil component_id = 1
| node.default[component_details][component_id] = ''
| customResource B "Get me component details" do:
| | comp_id component_id
| | action :get_component_details
| end
| Chef::log.info("See the output computed by my customResourceB")
| Chef::log.info(node[component_details][component_id])
end

注意事项:1. customResourceB的作用是对REST Web服务进行PS调用,并将JSON结果存储在覆盖其值的node [component_details] [component_id]中。我正在此资源上创建此属性节点,因为我知道稍后将使用它,从而避免了编译时问题。

我面临的问题:1.在测试在Chef-client中调用此资源的简单配方时,资源中的代码将执行到最后一个日志行,然后调用customResourceB。这是我不希望发生的事情。

任何建议将不胜感激。我对Chef也很陌生,因此也欢迎进行任何设计改进

ruby chef chef-recipe
1个回答
0
投票

无需嵌套厨师资源,而使用厨师idompotanceguardsnotification

并且通常,您始终可以使用条件来确定要运行的食谱\食谱。

© www.soinside.com 2019 - 2024. All rights reserved.