2013-06-12 97 views

回答

7

已解決。 SSH連接到我的情況下,則:

sudo opsworks-agent-cli get_json 

這說明我Opsworks JSON是合併廚師定製JSON ......還有就是我的圖層的名稱:

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

然後我用一些邏輯在我的食譜...

+0

這太棒了,謝謝! –

+0

我不相信這是有效的廚師12 :( – user1933131

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 
相關問題