chef

Overriding attributes in the recipe

。_饼干妹妹 提交于 2019-12-18 10:48:09
问题 Let's say I have a default attribute in a cookbook: default.nginx_upstreams = { 'service1' => ['service1.server.com'], 'service2' => ['service2.server.com'], } Then it gets modified and overridden in roles and environments until it finally gets to my recipe. There, I compute some additional services that I would like to add to the attribute. If I do something like this: node.nginx_upstreams.merge! {'service3' => ['service3.server.com']} then when I try to use the attribute in my template, I

Chef - How Reboot VM and continue performing actions

瘦欲@ 提交于 2019-12-18 06:56:39
问题 In a Chef recipe, I need to perform a reboot on a Node after doing some actions, and after the reboot is done, I need to continue doing another actions: Recipe: -action 1 -action 2 -reboot -action3 -action4.... I have checked some existing cookbook in the community: reboot-handler, chef-reboot, chef-restart, chef-dominous, but I cannot make any of them work. Is there some method in Chef to get what I need? Please provide detailed examples. Thanks a lot for the help. 回答1: How about using chef

How to use a Ruby block to assign variables in chef recipe

ぃ、小莉子 提交于 2019-12-18 05:21:46
问题 I am trying to execute Ruby logic on the fly in a Chef recipe and believe that the best way to achieve this is with a block. I am having difficulty transferring variables assigned inside the block to the main code of the chef recipe. This is what I tried: ruby_block "Create list" do block do to_use ||= [] node['hosts'].each do |host| system( "#{path}/command --all" \ " | awk '{print $2; print $3}'" \ " | grep #{host} > /dev/null" ) unless $? == 0 to_use << host end end node['hosts'] = to_use

I have installed chef-dk and started using berkshelf but berks upload failed

这一生的挚爱 提交于 2019-12-18 04:55:19
问题 I have installed chef client 12.0.3 , on top of it I have install chef-dk version 0.3.5 but why chef-dk is installing chef client version Chef: 11.18.0.rc.1 Unable to Upload cookbooks to chef server berks shelf list is working but berks upload failed Error: E, [2015-01-08T04:58:36.707534 #22533] ERROR -- : Ridley::Errors::ClientError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed E, [2015-01-08T04:58:36.708931 #22533] ERROR -- : /opt/chefdk

Chef: How do I override default attributes in roles?

寵の児 提交于 2019-12-17 18:07:15
问题 I'm using the opscode nginx cookbook for configuring the nginx server on my nodes. The nginx cookbook has some default attributes I'd like to override in my role ("web_server"). These are the attributes I'd like to override: default['nginx']['version'] = "1.2.2" # in cookbooks/nginx/attributes/default.rb default['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['version']}" # in cookbooks/nginx/attributes/source.rb In my roles/web_server.rb file I have something like this: name "web

How do I configure Chef Solo to install Nginx on a new Vagrant box?

∥☆過路亽.° 提交于 2019-12-17 17:58:27
问题 I'm new to Chef and the documentation (even the home page of their website) makes my head spin. I'm not even sure if I'm using it for the correct purpose. My intent is to setup a Vagrantfile that tells Chef Solo to install some software automatically when I spin up a new box. That is one of Chef Solo's intended uses, am I correct? I'm not really sure if that qualifies as one of "the hardest infrastructure challenges on the planet" , but whatever. My first goal is to get Chef Solo to install

How can I put the output of a Chef 'execute resource' into a variable

这一生的挚爱 提交于 2019-12-17 17:55:16
问题 I'd like to put the output of a shell command into a variable for later use in a Chef recipe. In bash I could do something like output=`tail -1 file.txt` and then I could echo $output Can an 'execute resource' do this so that I can use the result later in the recipe? 回答1: while Graham's solution seemed to work at first, I found out about Chef::Mixin:ShellOut ruby_block "check_curl_command_output" do block do #tricky way to load this Chef::Mixin::ShellOut utilities Chef::Resource::RubyBlock

How to control the version of Chef that Vagrant uses to provision VMs?

一笑奈何 提交于 2019-12-17 17:28:22
问题 A current Chef recipe isn't running because of a bug in version 0.10.10. How can I upgrade the version of Chef that Vagrant uses, to 0.10.12? I don't want to just update it for the current instance of the VM - I keep destroying and rebuilding those. Do I need to change something in the Vagrant base box, or something in my (physical) system's installation? 回答1: Using the Vagrant plugin vagrant-omnibus worked great for me: vagrant plugin install vagrant-omnibus You can then simply configure

Can the java cookbook be used to install a local copy of oracle java?

萝らか妹 提交于 2019-12-17 17:06:53
问题 I have been trying to learn chef recently because I was planning on using it for deploying server config and server application software. I am having issues understanding how to use other people's cookbooks. For example, I want to deploy JDK8u31. I can't figure it out how to implement this cookbook. https://supermarket.chef.io/cookbooks/java I read the instructions and I see the following Simply include the java recipe wherever you would like Java installed, such as a run list (recipe[java])

How can you use a Chef recipe to set an environment variable?

一笑奈何 提交于 2019-12-17 10:44:27
问题 How can you use a Chef recipe to set an environment variable? I need to set an environment variable using a Chef recipe. Can you provide an example of how to accomplish this? 回答1: If you need an env var set strictly within the Chef process, you can use ENV['foo'] = 'bar ' since it's a ruby process. If you need to set one for an execute provider, Chef exposes an environment hash: execute 'Bootstrap the database' do cwd "#{app_dir}/current" command "#{env_cmd} rake db:drop db:create db:schema