我遵循了教程http://gettingstartedwithchef.com/,第1章。我的运行list是"run_list":["recipe[apt]","recipe[phpap]"]我的phpapRecipe默认Recipeinclude_recipe"apache2"include_recipe"build-essential"include_recipe"openssl"include_recipe"mysql::client"include_recipe"mysql::server"include_recipe"php"include_recipe"php::modul
我在我的Rails3示例应用程序上使用CarrierWave。我想验证远程位置上传,因此当用户提交无效URL(空白或非图像)时,我不会收到标准错误异常:CarrierWave::DownloadErrorinImageController#createtryingtodownloadafilewhichisnotservedoverHTTP这是我的模型:classPaintingtrue,:length=>{:minimum=>5,:maximum=>100}validates:image,:presence=>trueend这是我的Controller:classPaintingsC
所以这可能有点令人困惑,但请耐心等待。简而言之,我想遍历具有特定键值的所有属性,然后如果值不为空,则将它们插入到模板中。这是我的代码:属性:#===DefaultfileConfigurations#default['elasticsearch']['default']['ES_USER']=''default['elasticsearch']['default']['ES_GROUP']=''default['elasticsearch']['default']['ES_HEAP_SIZE']=''default['elasticsearch']['default']['MAX_OP
我正在尝试将一个资源属性的默认值设置为另一个属性的值。我正在为我正在构建的tomcat说明书定义一个资源,其中包含以下定义。我想要可以独立设置的“名称”和“服务名称”属性。当未设置服务名称时,我希望它默认为为“名称”提供的任何内容。以下不符合我的预期:attribute:name,:kind_of=>String,:required=>true,:name_attribute=>trueattribute:service_name,:kind_of=>String,:default=>:name注意第二行末尾的“:default=>:name”。当我在Recipe的新block中引用我
我有以下代码,它下载一个文件,然后将文件的内容读入一个变量。使用该变量,它执行一个命令。这个配方不会收敛,因为/root/foo在编译阶段不存在。我可以通过多个聚合和一个来解决这个问题ifFile.exist但我想用一个收敛来完成它。关于如何做到这一点有什么想法吗?execute'download_joiner'docommand"awss3cps3://bucket/foo/root/foo"not_if{::File.exist?('/root/foo')}endpassword=::File.read('/root/foo').chompexecute'join_domain'd
这是我在ChefRecipe中的一blockRuby:#ifdatadirdoesn'texist,moveoverthedefaultoneif!File.exist?("/vol/postgres/data")execute"mv/var/lib/postgresql/9.1/main/vol/postgres/data"end结果是:Executingmv/var/lib/postgresql/9.1/main/vol/postgres/datamv:inter-devicemovefailed:`/var/lib/postgresql/9.1/main'to`/vol/post
我正在尝试实现state_machinegem,在我的rails项目中,我安装了gem,然后我将“state”列添加到我的account_entries模型中:defchangeadd_column:account_entries,:state,:stringend然后在我的account_entries模型中,我添加了状态机初始方法,如下所示:state_machine:state,:initial=>:submitteddoend然后在我看来我显示时间进入状态:account_entry.state但是当我尝试从我的应用程序创建一个account_entry时,我得到了这个错误:p
我正在为我正在处理的一些新ChefRecipe编写InSpec测试。我想利用Recipe使用的data_bags遍历数据包项。我不知道如何在我的InSpec测试中访问它们!这些Recipe使用了search、data_bag和data_bag_item方法。但是这些方法在我的InSpec测试中似乎不可用。我怀疑这些是ChefDSL特定的方法?data_bags的源代码受源代码控制,因此我可以在我的本地文件系统上访问它们的json。如何使用InSpec语法访问Chef_zero中的这些数据包?我在网上找到了几个示例,但我没有看到data_bags实际上是如何由chef_zero加载的,以
假设我们有两个资源:template'template1'doowner'root'group'root'endtemplate'template2'doowner'root'group'root'end我想在资源中重用代码。但是,如果我在配方中定义了一个过程,您会得到owner、group等的NoMethodError。为什么会这样?词法范围没有什么不同,是吗?因此,我必须使用self.instance_eval&common_cfg。common_cfg=Proc.new{owner'root'group'root'}template'template1'docommon_cfg.
使用chef我有一个安装gem的简单方法,例如:gem_package"passenger"doversionnode['passenger']['version']end我还想用另一本说明书安装ruby,对于某些服务器可能是Ruby1.9.3,对于其他服务器可能是RubyEnterprise1.8.7。所以我想我可以使用gem_binary和ohai来做到这一点,就像这样:gem_package"passenger"doversionnode['passenger']['version']gem_binary"#{languages['ruby']['bin_dir']/gem}