chef

download roles and cookbooks from ChefServer with knife

时光怂恿深爱的人放手 提交于 2020-01-01 05:02:51
问题 Given I started working with Chef using the Chef Server Management Console and I now want to start using a files and upload them via knife. Is there a way to retrive roles and environments that are stored on the ChefServer via knife, so I can them into git? 回答1: You can use the knife environment list and knife environment show commands to download environments and replace "environment" with "role" to do the same for roles. mkdir environments for env in `knife environment list`; do knife

Chef and erb templates. How to use boolean code blocks

社会主义新天地 提交于 2019-12-31 12:58:06
问题 I am new to chef, ruby, ruby DSL, and erb. I come from python. In a ruby erb template I want to do something like this. <% if node[:monit][:server]=='nginx' -%> ALL OF MY NGINX TEXT <% end -%> <% if node[:monit][:server]=='redis' -%> ALL OF MY REDIS TEXT <% end -%> Clearly I am missing something about proper syntax. Thanks 回答1: Try this: <% if node[:monit][:server]=='nginx' -%> nginx_text=<%= node[:nginx][:text] %> <% end -%> <% if node[:monit][:server]=='redis' -%> redis_text=<%= node[:redis

Chef clients and validators

痴心易碎 提交于 2019-12-31 09:24:40
问题 I'm trying to understand the concept of Chef clients and validators, and their relationship to the bootstrapping process. According to this article, the chef-client will use the /etc/chef/validation.pem private key to authenticate itself for the initial run, because /etc/chef/client.pem doesn't exist yet. This initial run will, somehow, produce that client.pem , which is then used for all subsequent client requests. My questions: What process places the /etc/chef/validation.pem file on the

Encrypt data bag from inside of ruby without relying on knife

好久不见. 提交于 2019-12-31 03:41:19
问题 At the moment to encrypt a data bag, I have to do : system "knife data bag from file TemporaryEncrypting \"#{enc_file_path}\" --secret-file #{Secret_Key_Path}" and that doesn't work because knife can't find a config file and I can't seem to get it read the one in C:\chef . How do I do this from within ruby? 回答1: I worked out how to encrypt inside of ruby, just use this code: require 'chef/knife' #require 'chef/encrypted_data_bag_item' #you need to do this in chef version 12, they've moved it

Bundle install is using a different Ruby version?

北慕城南 提交于 2019-12-30 20:12:46
问题 I tried to install Ruby 2.0.0-p353 on Vagrant using knife-solo. When I logged in as root and vagrant, ruby -v returns Ruby 2.0.0-p353. However, when I run bundle install in a Rails project, the following statement is displayed: Your Ruby version is 1.8.7, but your Gemfile specified 2.0.0 The default version of Ruby is 1.8.7, so I think bundle install is referring to this. What should I do to solve this problem? $ cat site-cookbooks/ruby/recipes/default.rb group 'rbenv' do action :create

Bundle install is using a different Ruby version?

半世苍凉 提交于 2019-12-30 20:11:35
问题 I tried to install Ruby 2.0.0-p353 on Vagrant using knife-solo. When I logged in as root and vagrant, ruby -v returns Ruby 2.0.0-p353. However, when I run bundle install in a Rails project, the following statement is displayed: Your Ruby version is 1.8.7, but your Gemfile specified 2.0.0 The default version of Ruby is 1.8.7, so I think bundle install is referring to this. What should I do to solve this problem? $ cat site-cookbooks/ruby/recipes/default.rb group 'rbenv' do action :create

Run all sql files with Chef

落爺英雄遲暮 提交于 2019-12-30 11:12:09
问题 Hello i need help i made a command that should read all the sql files inside of the sql_dumps folder but it isnt working.. here is what i got. execute "Run_SQL_Files" do dirResults = Dir.glob("/tmp/sql_dumps/*.sql") var = 0 while var < 15 do var = var + 1 command "mysql --user=root --password=toomba source" + dirResults[var] # Already tried this also # command "mysql --user=root --password=toomba < " dirResults[var] puts dirResults[var] end end I'am not very familiar with ruby. This is the

How can I edit a chef attribute of an ec2 node using knife

和自甴很熟 提交于 2019-12-30 04:55:06
问题 I want to edit ec2 node's node_data using a knife node command. I can manually do it by using below command. knife node edit NODE_NAME It will generate a json which I need to edit. "name": "NODE-1", 3 "chef_environment": "test", 4 "normal": { 5 "node_data": { 6 "version": "23690ecc9c572e47db242bfad1296388f91da1e9", 7 "depot_path": "https://s3.amazonaws.com/builds/", 8 "source_repo": "softwares/" 9 }, 10 "tags": [ 11 12 ] 13 }, 14 "run_list": [ 15 "role[my-role]" 16 ] 17 } I want to edit node

How to lazily evaluate an arbitrary variable with Chef

不问归期 提交于 2019-12-30 03:04:08
问题 I'm writing a Chef recipe to install our application code and execute it. The recipe needs to be particular about the directory this code ends up in (for running templates, setting log forwarding etc.). Thus the directory itself pops up in a lot of places in different recipes. I am trying to fetch/define a variable so I can re-use it in my resource block with string interpolation. This is pretty straightforward: home = node['etc']['passwd'][node['nodejs']['user']]['dir'] With an example usage

How to customise a tomcat recipe in Chef

吃可爱长大的小学妹 提交于 2019-12-29 01:57:25
问题 I've been trying to customise a tomcat chef recipe but nothing I'm doing seems to change the tomcat installation. I'm using vagrant ie. vagrant destroy && vagrant up In Vagrantfile config.vm.provision :chef_solo do |chef| chef.add_recipe "apt" chef.add_recipe "nginx-app" chef.add_recipe "tomcat-app" end cookbooks/tomcat-app/recipes/default.rb # # Cookbook Name:: tomcat-app # Recipe:: default package "tomcat7" do action :install end cookbooks/tomcat-app/attributes.rb node.default["tomcat"][