天道酬勤,学无止境

cookbook

Chef Ruby 循环遍历 .erb 模板文件中的属性(Chef Ruby loop over attributes in an .erb template file)

问题 所以这可能有点令人困惑,但请耐心等待。 简而言之,我想遍历具有某个键值的所有属性,然后如果这些值不为空,则将它们插入到模板中。 这是我的代码: 属性: # === Default file Configurations # default['elasticsearch']['default']['ES_USER'] = '' default['elasticsearch']['default']['ES_GROUP'] = '' default['elasticsearch']['default']['ES_HEAP_SIZE'] = '' default['elasticsearch']['default']['MAX_OPEN_FILES'] = '' default['elasticsearch']['default']['MAX_LOCKED_MEMORY'] = 'unlimited' default['elasticsearch']['default']['MAX_MAP_COUNT'] = '' default['elasticsearch']['default']['LOG_DIR'] = '/var/log/elasticsearch' default['elasticsearch']['default']['DATA_DIR'] = '/var/lib

2021-06-11 15:58:53    分类:技术分享    ruby   elasticsearch   chef-infra   cookbook   chef-template

How to query cookbook versions on a node?

Usage case: The DevOps team launched a node sometime ago, and my team would like to know what's the version(s) of one/several cookbook(s) being used in the run_list. Our DevOps team is firefighting so we'd like to find a way to be self-sufficient. Commands Tried: knife cookbook show COOKBOOK give all possible versions, but does not specify which one being used. knife node show NODE shows all cookbooks, but there's no version info attached. Question: Is there a command (something similar to knife search, ohai) to query the chef-server for the versions deployed on the node?

2021-06-01 13:29:01    分类:问答    chef-infra   chef-recipe   knife   cookbook

Chef Ruby loop over attributes in an .erb template file

So this might be a little confusing but bear with me. In short I want to loop over all attributes with a certain key value and then insert them into a template if the values are not empty. Here is my code: ATTRIBUTES: # === Default file Configurations # default['elasticsearch']['default']['ES_USER'] = '' default['elasticsearch']['default']['ES_GROUP'] = '' default['elasticsearch']['default']['ES_HEAP_SIZE'] = '' default['elasticsearch']['default']['MAX_OPEN_FILES'] = '' default['elasticsearch']['default']['MAX_LOCKED_MEMORY'] = 'unlimited' default['elasticsearch']['default']['MAX_MAP_COUNT'] =

2021-05-31 16:43:46    分类:问答    ruby   elasticsearch   chef-infra   cookbook   chef-template

如何在厨师ruby_block中要求我的图书馆(how to require my library in chef ruby_block)

问题 我正在开发一本食谱,以部署一个简单的ROR应用程序。 我编写了一个app_helper.rb并将其放入我的食谱的库目录中,内容如下: module AppHelper def self.find_gem if File.exists?("/usr/local/rvm/bin/rvm") return `/usr/local/rvm/bin/rvm default exec which gem`.chomp else return "/usr/bin/gem" end end end 在配方/default.rb中,我将上述模块混入Chef :: Recipe类 class Chef::Recipe include AppHelper end 如您所知,可以从配方的任何位置调用find_gem函数。 当我试图在我的ruby_block中使用find_gem函数时,如下所示: ruby_block "find gem" do block do gem_bin = Chef::Recipe::find_gem # or gem_bin = find_gem end end 我收到一个NoMethodError:未定义的方法'find_gem'。 也可以尝试将模块混入Chef :: Resource :: RubyBlock中,这两种方法都不起作用。 class Chef

2021-05-24 16:27:54    分类:技术分享    chef-infra   cookbook

How run cookbook with dependencies in chef?

I have configured workstation up this step in get started (OS redhat 6.5). I have launched a node. I modified a cookbook like that: myCookbook/metadata.rb name 'myCookbook' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures myCookbook' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.1.0' depends 'maven' E.g. only depends 'maven' string was added after knife cookbook create myCookbook was executed. myCookbook/recipes/default.rb maven 'spring-context' do group_id 'org.springframework'

2021-05-13 08:24:52    分类:问答    java   ruby   maven   chef-infra   cookbook

how to require my library in chef ruby_block

I'm developing a cookbook to deploy a simple ROR application. I write an app_helper.rb and put it into the libraries directory of my cookbook, here is the content: module AppHelper def self.find_gem if File.exists?("/usr/local/rvm/bin/rvm") return `/usr/local/rvm/bin/rvm default exec which gem`.chomp else return "/usr/bin/gem" end end end In the recipes/default.rb, I mix in the above module into Chef::Recipe class class Chef::Recipe include AppHelper end As you know, the find_gem function can be called from anywhere of the recipe. when I'm trying to use the find_gem function in my ruby_block

2021-04-27 15:29:08    分类:问答    chef-infra   cookbook

如何在Cloudant / CouchDB中使用我的SQL知识?(How can I use my sql knowledge with Cloudant/CouchDB?)

问题 一些具有查询SQL数据库的丰富知识的开发人员正在努力在Cloudant / CouchDB中实现等效的查询模式。 这些开发人员如何将他们的SQL知识转换为Cloudant / CouchDB? 回答1 该社区Wiki页面提供了一些SQL模式的链接,这些模式显示了如何在Cloudant中实现它们。 由于这是社区Wiki,请随时在此处添加新的问答链接。 通用数据库查询 通过密钥加入两个文档? 在CouchDB中,SQL如何等效于“ DISTINCT”? 如何在CouchDB中进行三重联接? 通过文档字段进行内部联接? 我该如何进行子查询? 如何进行一对多加入? 如何进行多对多联接? 多个WHERE和OR子句在...查询中在...不在查询中跨数据库执行查询我可以在CouchDB中进行交易和锁定吗? Cloudant SQL Join食谱在此处添加新的问答链接... 汇总数据库查询 COUNT(*)个聚合函数? SUM * GROUP BY查询? 在此处添加新的问答链接... 全文查询(lucene)-仅Cloudant 在此处添加新的问答链接... 也可以看看 查看有关SQL骑师的食谱

2021-04-10 11:41:41    分类:技术分享    sql   couchdb   cloudant   cookbook   recipe

How can I use my sql knowledge with Cloudant/CouchDB?

Some developers who have a good knowledge of querying SQL databases struggle to implement the equivalent query patterns in Cloudant/CouchDB. How can these developers translate their SQL knowledge to Cloudant/CouchDB?

2021-03-29 17:04:02    分类:问答    sql   couchdb   cloudant   cookbook   recipe