chef

How to set environment variable using Chef?

安稳与你 提交于 2019-11-30 15:03:08
问题 Theres a similar question to this, but cant manage it to work: I want to simply set an env variable, then use it: execute "start zookeeper" do cwd "/opt/zookeeper-3.4.5/bin" command "./zkServer.sh start" environment "JVMFLAGS" => "-Xmx#{heap_jvm} -Xms#{heap_jvm}" user "root" action :run end I've also tried using bash to "export JVMFLAGS='-blabla'" but still it runs the sh with none set to the variable. Is there some issue preventing my sh script from checking the variable? I could use the sh

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

旧城冷巷雨未停 提交于 2019-11-30 14:37:54
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_data in that json. If I had to edit run_list the there is a command for that knife node run_list add

Testing Chef roles and environments

我的梦境 提交于 2019-11-30 13:21:38
I'm new to Chef and have been using Test Kitchen to test the validity of my cookbooks, which works great. Now I'm trying to ensure that environment-specific attributes are correct on production nodes prior to running Chef initially. These would be defined in a role. For example, I may have recipes that converge using a Vagrant box with dev settings, which validates the cookbook. I want to be able to test that a production node's role. I think I want these tests as the source of truth describing my environment. Looking at Test Kitchen's documentation, this seems beyond its scope. Is my

Chef on Vagrant Box: Can't find encrypted data bag secret

僤鯓⒐⒋嵵緔 提交于 2019-11-30 12:40:38
问题 When provisioning a vagrant box with (hosted-)chef I get the following error: No such file or directory - file not found '/tmp/encrypted_data_bag_secret' Here is the call causing the error: ssl = Chef::EncryptedDataBagItem.load("ssl", s[:id]) I also can't find the encrypted_data_bag_secret in /etc/chef where it normally resides on my other servers. Am I missing a config which uploads the data bag secret? Here's the rest of the stack trace: [2013-02-14T16:51:15+00:00] ERROR: Running exception

Vagrant, Docker, Puppet, Chef

回眸只為那壹抹淺笑 提交于 2019-11-30 12:21:19
问题 I don't understand even the basic difference between the services in the title. Do these services just provide software to help you configure/organize/manage your VM's, or do they also provide physical infrastructure for your VM's to run on? In other words, are they just convenient interfaces between developers and AWS, Rackspace, and Azure? 回答1: Not exactly. Chef/Puppet are the "same", they are configuration management. While you can use them to manage virtual machines or public/private

/usr/bin/env ruby_noexec_wrapper fails with no file or directory

一个人想着一个人 提交于 2019-11-30 11:38:46
When I try to start chef-solr as service it's failing with the following error # service chef-solr start Starting chef-solr: /usr/bin/env: ruby_noexec_wrapper: No such file or directory [FAILED] But when I run it manually from command line it's running successfully # chef-solr -d -c /etc/chef/solr.rb -L /var/log/chef/solr.log -P /var/run/chef/solr.pid # echo $? 0 # ps -ef | grep chef root 2691 1 12 04:19 ? 00:00:01 java -Xmx256M -Xms256M -Dsolr.data.dir=/var/lib/chef/solr/data -Dsolr.solr.home=/var/lib/chef/solr/home -jar /var/lib/chef/solr/jetty/start.jar Here is my rvm info # rvm info ruby-1

how to require my library in chef ruby_block

本秂侑毒 提交于 2019-11-30 11:29:37
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

How to lazily evaluate an arbitrary variable with Chef

混江龙づ霸主 提交于 2019-11-30 08:47:00
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 being to run npm install while telling it to plunk the repo downloads in the home directory, like this

How can I display the output of a Opscode Chef bash command in my console?

送分小仙女□ 提交于 2019-11-30 08:38:09
I use Vagrant to spawn a standard "precise32" box and provision it with Chef so I can test my Node.js code on Linux when I work on a Windows machine. This works fine. I also have this bash command so it auto installs my npm modules: bash "install npm modules" do code <<-EOH su -l vagrant -c "cd /vagrant && npm install" EOH end This also works fine except that I never see the console output if it completes successfully. But I'd like to see it so we can visually monitor what is going on. This is not specific to npm. I see this similar question with no concrete answers: Vagrant - how to print

How can I access the current node from a library in a Chef cookbook?

ぃ、小莉子 提交于 2019-11-30 08:33:14
问题 I'm attempting to write a library for a chef cookbook that simplifies some common searches. For example, I'd like to be able to do something like this in cookbook/libraries/library.rb and then use it from a recipe in the same cookbook: module Example def self.search_attribute(attribute_name) return search(:nodes, node[attribute_name]) end end The problem is that, inside a Chef library file neither the node object or search function are available. Search seems to be possible by using Chef: