我正在尝试与Chef一起启动EC2实例。一切都运行良好,但Chef似乎无法标记实例。我错过了什么吗?否则,实现此目标的首选Ruby库是什么?我可以在不需要额外gem的情况下做到吗?谢谢 最佳答案 knife-ec2Gem的0.5.12版支持在创建时使用--tags选项标记EC2实例。knifeec2servercreate[...youroptions...]--tagsTag=Value 关于ruby-如何在Chef中使用Ruby标记EC2实例?,我们在StackOverflow上找到
我是Ruby的新手,但过去两周我一直在对Chef测试进行大量研究。该测试使用ChefSpec和Fauxhai,但它看起来不是很“像ruby”,我希望社区能给我一些编码风格的建议。有没有更好的方法来编写这样的嵌套循环?Recipe/foo/recipes/default.rbpackage"foo"doaction:installendRecipe/foo/spec/default_spec.rbrequire'chefspec'describe'foo::default'doplatforms={"debian"=>['6.0.5'],"ubuntu"=>['12.04','10.04
我正在尝试为ChefRecipe编写一个库,以简化一些常见的搜索。例如,我希望能够在cookbook/libraries/library.rb中执行类似的操作,然后从同一Recipe中的Recipe中使用它:moduleExampledefself.search_attribute(attribute_name)returnsearch(:nodes,node[attribute_name])endend问题是,在Chef库文件中,node对象或search函数都不可用。似乎可以使用Chef::Search::Query.new().search(...)进行搜索,但我找不到任何可以访
Chef能否支持更新版本的Ruby,即2.0.0?如果不是,是否有原因?在文档中它指定了1.9.2https://wiki.opscode.com/display/chef/System+Requirements+with+install(死链接) 最佳答案 Chef11.6+支持Ruby2.0。低于该版本的版本仅适用于Ruby1.8和1.9。来源:我在Opscode工作我在Ruby2.0、1.9和1.8上使用Chef 关于Chef的Ruby版本,我们在StackOverflow上找到一
当我运行时::$vagrantprovision或:$vagrantup我有一个错误:nisevi@localhostprocessor(master):$vagrantprovisionUsingsshdeploykeyof:/home/nisevi/.ssh/id_rsa==>default:Chef12.0.3Omnibuspackageisalreadyinstalled.==>default:Runningprovisioner:shell...default:Running:inlinescript==>default:W==>default::==>default:Dup
我有一些nginx站点的资源和提供程序,它可以为站点写出配置文件。action:startdotemplate"/etc/nginx/sites-enabled/my_site"dosource"nginx_site.conf.erb"notifies:reload,"service[nginx]"endend当我从另一本Recipe中使用它时,找不到模板nginx_site.conf.erb,因为Chef正在寻找调用此资源的模板。有没有办法告诉Chef在nginx资源和提供者Recipe中寻找模板? 最佳答案 您可以为templa
我正在尝试使用Vagrant创建我的第一个ChefRecipe,但在第一步就遇到了问题。我的Recipe的第一行是:include_recipe"apt"但是当我尝试vagrantprovision时,出现以下错误:==>default:[2014-09-21T07:15:42+00:00]WARN:MissingCookbookDependency:==>default:Recipe`apt`isnotintherun_list,andcookbook'apt'==>default:isnotadependencyofanycookbookintherun_list.Toloadth
您将如何制作具有人类可读json的erb模板?下面的代码有效,但它生成了一个平面json文件默认.rbdefault['foo']['bar']={:herp=>'true',:derp=>42}Recipe.rbtemplate"foo.json"dosource'foo.json.erb'variables:settings=>node['foo']['bar'].to_jsonaction:createendfoo.json.erb类似的SO问题Chefandrubytemplates-howtoloopthoughkeyvaluepairs?HowcanI"pretty"for
假设我有一个变量directory_list,我在名为get_directory_list的ruby_block中定义和设置了它。我可以稍后在我的Recipe中使用directory_list吗,或者编译/收敛过程会阻止这种情况吗?例子:ruby_block"get_file_list"doblockdotransferred_files=Dir['/some/dir/*']endendtransferred_files.eachdo|file|file"#{file}"dogroup"woohoo"user"woohoo"endend 最佳答案
我有一个序列化的JSON字符串(实际上是chef角色定义),它有一个json_class键,使rubyJSON解析器试图强制它成为一个Chef::Role对象。我怎样才能让解析器忽略这个键,只是简单地反序列化成一个普通的哈希? 最佳答案 我遇到了同样的问题,通过阅读JSONgem的源代码找到了答案——在尝试解析之前取消设置JSON.create_id:JSON.create_id=nilJSON.parse('{"json_class":"Chef::Role"}').class=>Hash编辑:请注意,由于gem的版本为1.7