草庐IT

chef-infra

全部标签

ruby - Chef 执行非顺序配方

我遵循了教程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

ruby - Chef Ruby 遍历 .erb 模板文件中的属性

所以这可能有点令人困惑,但请耐心等待。简而言之,我想遍历具有特定键值的所有属性,然后如果值不为空,则将它们插入到模板中。这是我的代码:属性:#===DefaultfileConfigurations#default['elasticsearch']['default']['ES_USER']=''default['elasticsearch']['default']['ES_GROUP']=''default['elasticsearch']['default']['ES_HEAP_SIZE']=''default['elasticsearch']['default']['MAX_OP

ruby - Chef LW 资源属性默认值如何引用另一个属性?

我正在尝试将一个资源属性的默认值设置为另一个属性的值。我正在为我正在构建的tomcat说明书定义一个资源,其中包含以下定义。我想要可以独立设置的“名称”和“服务名称”属性。当未设置服务名称时,我希望它默认为为“名称”提供的任何内容。以下不符合我的预期:attribute:name,:kind_of=>String,:required=>true,:name_attribute=>trueattribute:service_name,:kind_of=>String,:default=>:name注意第二行末尾的“:default=>:name”。当我在Recipe的新block中引用我

ruby - Chef : Read variable from file and use it in one converge

我有以下代码,它下载一个文件,然后将文件的内容读入一个变量。使用该变量,它执行一个命令。这个配方不会收敛,因为/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

ruby - 在 Ruby + Chef 中检查现有目录失败

这是我在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

ruby - 在 Amazon OpsWorks 上使用 Ruby 2.0

我想在AmazonOpsWorks上使用Ruby2.0,所以我正在尝试以下操作:选择自定义Recipe并将它们设置到我的forkhttps://github.com/aws/opsworks-cookbooks在此处更新所有版本号https://github.com/aws/opsworks-cookbooks/blob/master/ruby/attributes/ruby.rb到2.0值。虽然这似乎没有任何效果。自定义说明书是否会覆盖其内置的说明书?OpsWorks是否使用Recipe中的Ruby配方来进行基本的Ruby设置?同样的问题也适用于Nginx-我可以通过更改Recipe

ruby - 如何在 InSpec 中访问 Chef data_bags

我正在为我正在处理的一些新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加载的,以

ruby - block 看不到方法( Chef 资源)

假设我们有两个资源: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.

ruby - Chef Ohai : how to use newly installed Ruby with gem_package

使用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}

ruby - 您如何模块化 Chef Recipe ?

这是一个工作配方示例,它循环访问网站名称数组并使用函数createIisWebsite()在IIS中创建它们。defcreateIisWebsite(websiteName)iis_sitewebsiteNamedoprotocol:httpport80path"#{node['iis']['docroot']}/#{websiteName}"host_header"#{websiteName}.test.kermit.a-aws.co.uk"action[:add,:start]endend在我们的实际解决方案中,这些数据存储在别处并通过WebAPI访问。websiteNames=[