繁体   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