[英]How can I tag an EC2 instance using Ruby in Chef?
I'm playing around with Chef to launch EC2 instances. 我正在和Chef一起推出EC2实例。 Everything is working pretty well, but Chef doesn't seem to have the ability to tag the instances.
一切都运行良好,但厨师似乎没有能力标记实例。 Am I missing something?
我错过了什么吗?
Otherwise, what's the preferred Ruby library for achieving this? 否则,实现这一目标的首选Ruby库是什么? Can I do it without requiring additional gems?
我可以不需要额外的宝石吗?
Thanks 谢谢
knife-ec2
-ec2 Gem版本0.5.12支持使用--tags
选项在创建时标记EC2实例。
knife ec2 server create [... your options...] --tags Tag=Value
Know this is old, but was browsing about and spotted it. 知道这是旧的,但正在浏览并发现它。 Another alternative is to use the AWS community cookbook - assuming you have key creds - if you want to do things programatically as part of the recipe.
另一种选择是使用AWS社区食谱 - 假设您有关键信誉 - 如果您想以编程方式执行某些操作。
aws = data_bag_item('mydatabag', 'creds')
aws_resource_tag node['ec2']['instance_id'] do
aws_access_key aws['access_key']
aws_secret_access_key aws['secret_key']
tags({
"foo" => "bar"
})
action :update
end
Usually chef is used to install things on the instance. 通常,chef用于在实例上安装东西。 I'm not exactly sure how you start a node with chef, but maybe you can share this and I'll extend my answer?
我不确定你是如何与厨师一起创建一个节点的,但也许你可以分享这个,我会扩展我的答案吗?
Otherwise, fog is a great library to do these things. 否则, 雾是做这些事情的好图书馆。 I just skimmed over the source and it seems to support tagging as well.
我只是浏览了源代码,它似乎也支持标记。
To get fog: gem install fog
. 弄雾:
gem install fog
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.