在一個配方中,我有一個rubyblock,最終獲得我想要重新啓動的服務的端口。將變量從一個廚師食譜發送到另一個,以觸發資源塊
單獨的食譜工作正常,我現在試圖將兩者結合在一起。
我似乎無法將變量傳遞給試圖遵循自定義資源示例的其他配方。
,其取得上述端口我的默認食譜是:
Chef::Log.info("Port: #{port}")
Chef::Resource::Notification.new("stop-solr_#{port}", :run, self)
我試圖觸發使用通知發件人名稱爲「停止solr_'portNumber」的資源塊。
我的其他配方如下所示,具有起動/停止服務宗旨
solrCore = "solr_#{port}"
#define the service - does nothing
service solrCore do
action :nothing
end
#do something that triggers
execute "start-solr_#{port}" do
Chef::Log.info('triggers start')
action :nothing
notifies :start, run_context.resource_collection.find(:service => "#{solrCore}")
end
execute "stop-solr_#{port}" do
# some stuff
# on success...
Chef::Log.info('triggers restart')
notifies :stop, run_context.resource_collection.find(:service => "#{solrCore}"), :immediately
notifies :run, "execute[start-solr_#{port}]"
end
我的主要問題(我認爲)是變量solrCore使用「口」,這我似乎無法獲得。
任何人都可以幫助我做什麼,爲了得到這個工作嗎?
在此先感謝。
這就是'node.run_state'是。看到這裏的文檔:https://docs.chef.io/recipes.html#node-run-state – Tensibai
@Tensibai - 謝謝你,我會看看 – null