我正在尝试通过chef_handlerlwrp安装一个chefhandler。此处理程序(chef-handler-email)捆绑在一个gem中。我正在尝试安装gem,然后从如下所示的单个配方中打开处理程序:chef_gem"chef-handler-mail"chef_handler"MailHandler"dosource'chef/handler/mail'arguments:to_address=>"root"action:nothingsupports:exception=>true,:report=>falseend.run_action(:enable)如果gem已经安
是否可以在另一个Recipe提供者/库中重用Recipe库中的代码?cookbook1/libraries/lib.rb...defvery_useful_checktrueend...cookbook2/libraries(providers?)/foo.rb...myvar=very_useful_check...谢谢 最佳答案 可以使用ChefLibraries.确保函数是通过ruby模块在您的命名空间中定义的:moduleFoodefvery_useful_checktrueendendclassChef::Recipe
我有两个execute资源,名为command_1和command_2。如果command_1失败,我想运行command_2然后重新运行command_1。差不多是这样的:execute'command_1'docommand"ipahost-del#{machine_name}"action:runignore_failuretrueon_failure{notifies:run,'execute['command_2']',:immediately}endexecute'command_2'docommand"ipahost-mod--certificate#{machine_n
场景:方法1:下载文件,解压它们。提供一个CLI,它还定义了一个Ruby库。秘诀2:利用上述库中的RubyAPI。在recipe1/recipes/default.rb中:..doworknode[:recipe1][:filePath]=".."#pathtofile在recipe2/recipes/default.rb中:requirenode[:recipe1][:filePath]/lib/Library..dowork但是,当加载Recipe时,Chef宣布:[Wed,17Aug201119:32:23+0800]DEBUG:Loadingcookbookapache2'sd
我正在编写使用chef-solo安装jsk的练习方法,我需要更新.bashrc文件以设置JAVA_HOME和PATH变量。我不知道该怎么做。谁能告诉我该怎么做。我的一些代码是..file"/home/user/.bashrc"doowner"root"#somethinggoeshere....idon'tknowwhat.butiwrite#%{bash-i-c"source/etc/bash/bashrc&&bashrcupdate"}content"JAVA_HOME=/usr/java/jdk1.1.0.05"content"PATH=$PATH:JAVA_HOME/bin"e
我希望能够使用比方说3个参数来定义轻量级资源,其中两个是基本/基本参数,第三个是这两个参数的组合。我还想提供定制第三个参数的可能性。例如:如何修改以下代码以实现full_name属性的上述行为:资源定义:actions:installattribute:name,:kind_of=>String,:name_attribute=>trueattribute:version,:kind_of=>Stringattribute:full_name,:kind_of=>String提供商定义:action:installdoChef::Log.info"#{new_resource.full
我在Chef中使用环境,我想使用每个环境的运行列表。问题是我不想重复自己(就像我现在做的那样)。示例:{"name":"myapp","default_attributes":{},"json_class":"Chef::Role","env_run_lists":{"production":[#Haslesspackagesbecauseservicesarespreadacrossspecializednodes"role[base]","recipe[mysql::client]","recipe[myapp]"],"staging":[#Haslesspackagesbecau
我正在尝试将要部署的git分支传递给Chef部署资源,但它不起作用,我猜这是因为资源是单独编译然后才执行的?但我对Ruby的理解可能是有限的。所以我正在尝试这样做:ruby_block'revision'doblockdo#Somecodedeterminesthebranchtobedeployedbranch='master'node.run_state['branch']=branchendenddeploy"#{node['path']['web']}"doaction:deployrepository"#{node['git']['repository']}"revision
在vagrant、macosx10.7.2上运行Ubuntu11.04。运行Chef服务器。尝试安装postgresql社区ChefRecipe时,我收到以下错误,即使我的基本角色看起来像这样(我添加了aptRecipe以尝试更新apt-get):name"base"description"Thebaseroleforsystems"run_list("recipe[apt]","recipe[vim]")尝试运行Chef:$vagrantreloaddb1dev[db1dev]Attemptinggracefulshutdownoflinux...[db1dev]Preparingh
我正在尝试创建一个LWRP,它将调用在其自身中定义的资源。我的Recipe结构如下:在机器Recipe的提供者中,我有如下代码片段:require'chef/provisioning'#driverforcreatingmachinesrequire'::File'defget_environment_json@@environment_template=JSON.parse(File::read(new_resource.template_path+"environment.json"))return@@environment_templateend代码只是试图读取一个json文件,