chef

How to Run for each loop in template chef

自作多情 提交于 2020-01-25 14:33:13
问题 I have a attribute in the form of array, and i want to iterate over it in Chef template ? <% node['db2']['instance_username'].each do |device| -%> <%= "/home/#{device}/sqllib/lib64" %> <% end -%> I'm doing like this but it is giving error. 回答1: <% node['db2']['instance_username'].each do |device| %> /home/<%= device %>/sqllib/lib64 <% end %> I'd rewrite it like this instead. If you are having an error try taking out the end hyphens out they are a rails construct and I'm not sure if they cross

Elasticsearch file-based index templates not showing up in “/_template” API call

五迷三道 提交于 2020-01-25 14:30:33
问题 I'm attempting to automate the usage of index templates in Elasticsearch, so I've started creating the files in the "[ES_CONFIG_DIR]/templates/" directory (http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#config) with the proper format (sample file: http://pastebin.com/waKCBGgW). My Chef cookbook performs the following steps: 1.Create the JSON template file in the "[ES_CONFIG_DIR]/templates/tpl_misc.json" directory 2.Restart the elasticsearch service The

“cannot load such file — chef/rest” when “require 'chef/rest'”

痴心易碎 提交于 2020-01-25 10:34:05
问题 Trying to write first program to access chef server via API. Following example program on https://docs.chef.io/api_chef_server.html#examples there supposed to be two lines of code to include chef::rest library. require 'chef' require 'chef/rest' but the code failed with error Traceback (most recent call last): 2: from ./rest.rb:4:in `<main>' 1: from /opt/chef/embedded/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require' /opt/chef/embedded/lib/ruby/site_ruby/2.5.0

bluepill not detecting that processes have, in fact, started successfully, and so creates new ones

天涯浪子 提交于 2020-01-25 06:07:12
问题 I have one (EC2) Ubuntu server where bluepill is working just fine to start and monitoring resque processes (and it has done so on other nodes in the past). I'm setting up a new node, and for some reason on this node bluepill does not recognize that the processes have started and are running, and so keeps creating new ones. I'm a little baffled by what's causing this. The 2 nodes are almost identical; they're both EC2 servers provisioned by the same chef scripts. It is true that the one not

bluepill not detecting that processes have, in fact, started successfully, and so creates new ones

流过昼夜 提交于 2020-01-25 06:04:04
问题 I have one (EC2) Ubuntu server where bluepill is working just fine to start and monitoring resque processes (and it has done so on other nodes in the past). I'm setting up a new node, and for some reason on this node bluepill does not recognize that the processes have started and are running, and so keeps creating new ones. I'm a little baffled by what's causing this. The 2 nodes are almost identical; they're both EC2 servers provisioned by the same chef scripts. It is true that the one not

How to extend a lightweight provider in Chef

时光总嘲笑我的痴心妄想 提交于 2020-01-21 05:00:07
问题 I am creating a bunch of different Chef providers to deploy different types of applications. Chef's documentation for Extend a Lightweight Provider suggests it is possible but doesn't actually say what to do. That page suggests that perhaps a call to mixin is needed, but I don't know what structure my code should have in the file under /libraries or how to actually include that code in something under /providers . Here are the examples of what I want to do. In my base class under /libraries :

Installing RVM/Ruby 1.9.3 via Chef

笑着哭i 提交于 2020-01-17 07:40:12
问题 I'm just getting started with trying to move my infrastructure over to Chef, and I think I must be missing something obvious. I'm using the chef-rvm cookbook to install RVM, and I'd like it to install Ruby 1.9.3p125 and set that as the default. Here's my base server role: name "base" description "Basic configuration for all nodes" run_list( 'recipe[git]', 'recipe[sudo]', 'recipe[ubuntu]', 'recipe[rvm]', 'recipe[postgresql::client]' ) override_attributes( :authorization => { :sudo => { :users

is it possible to use supports statement in if statement in chef?

前提是你 提交于 2020-01-17 04:15:09
问题 what I'm trying to do is I want to write into a file if the service is running as RUNNING and if not, as NOT RUNNING. service 'McAfeeFramework' do puts 'true' only_if{ supports :status =>true} File.write('c:\chef-repo\n1.txt','running') puts 'false' only_if{ supports :status =>false} File.write('c:\chef-repo\n1.txt','not running') end 回答1: You are trying to use the service resource wrong. A service resource can be used to manage a service in the system, like enabling, disabling, starting or

Knife ssh not loading environment variables

心不动则不痛 提交于 2020-01-17 03:52:25
问题 On my node node_name I've got $JAVA_HOME and other environment variables set in /etc/profile . I'm aware (found that out) that knife ssh isn't a login shell, and so doesn't load the environment variables. Is there a way to load the environment variables without having to source it? Right now I'm forced to do knife ssh 'name:nod_name' 'source /etc/profile; echo $JAVA_HOME' I'm chaining in a few commands during knife ssh including some of the environment variables and loading the /etc/profile

Knife ssh not loading environment variables

霸气de小男生 提交于 2020-01-17 03:52:04
问题 On my node node_name I've got $JAVA_HOME and other environment variables set in /etc/profile . I'm aware (found that out) that knife ssh isn't a login shell, and so doesn't load the environment variables. Is there a way to load the environment variables without having to source it? Right now I'm forced to do knife ssh 'name:nod_name' 'source /etc/profile; echo $JAVA_HOME' I'm chaining in a few commands during knife ssh including some of the environment variables and loading the /etc/profile