簡體   English   中英

Chef運行期間的AWS OpsWorks Layer

[英]AWS OpsWorks Layer during Chef run

我想將自定義JSON傳遞給我的廚師運行,但顯然這只能用於整個堆棧。 我可以使用JSON上的圖層名稱/ ID和所需的數據,但是我如何檢查廚師正在努力實施的圖層?

解決了。 SSH連接到我的實例,然后:

sudo opsworks-agent-cli get_json

這向我展示了與Chef Custom JSON合並的Opsworks JSON ......並且有我的圖層名稱:

node["opsworks"]["instance"]["layers"][0]

然后我在我的食譜中使用了一些邏輯......

有廚師12:

來自: https//forums.aws.amazon.com/thread.jspa?threadID = 190405

node_instance = search(:node, "hostname:#
{node['hostname'].upcase}").first
Chef::Log.info "This is an instance object as returned by Chef Server. 
EC2 Instance ID is #{node_instance['ec2']['instance_id']}"

aws_instance = search(:aws_opsworks_instance, "hostname:#
{node['hostname'].upcase}").first
Chef::Log.info "This is the AWS OpsWorks instance object. It has AWS 
OpsWorks specific attributes, like the Layer IDs for the instance: #
{aws_instance['layer_ids'].join(',')}"

aws_instance['layer_ids'].each do |layer_id|
  layer = search(:aws_opsworks_layer, "layer_id:#{layer_id}").first
  Chef::Log.info "The instance belongs to layer #{layer['layer_id']}, 
it's name is #{layer['name']}"
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM