chef-recipe

Executing chef recipe only after another recipe is finished

倾然丶 夕夏残阳落幕 提交于 2019-12-10 12:26:48
问题 I have two recipes in different cookbooks. I need the first recipe to be completely finished before the second one starts execution, as it places some files that the second will need. I put the first one before the second in the run list, but it seems as if they get executed in parallel. How can I trigger the second recipe's execution when the first is done? (Note that they are in different cookbooks.) 回答1: Can you post a snippet of the code. My guess is that you're making use of LWRP

Is there a way to use “knife search node” or “knife show node” that will tell you the cookbook/recipe version being used?

这一生的挚爱 提交于 2019-12-10 11:55:26
问题 knife node show my_chef_node will give you information like the recipes, roles, etc. but ideally what I want is to be able to see the version of those cookbook recipes as well. knife search node 'recipes:my_cookbook\:\:default' returns nodes but knife search node 'recipes:my_cookbook\:\:default@0.3.1' does not. 回答1: Unless you constrain the runlist it will be calculated at runtime. Determining this just by looking at the cookbook versions loaded into the server is very hard. How does one

Disable ssl on Chef-server?

吃可爱长大的小学妹 提交于 2019-12-10 10:49:21
问题 I have setup nginx['enable_non_ssl']=true in the /etc/opscode/chef-server.rb file and run chef-server-ctl reconfigure but I still get a redirect when I try to curl the http port for chef which kind of defeats the purpose of this setting. See errors below. My chef-server.rb file: cat /etc/opscode/chef-server.rb nginx['enable_non_ssl']=true nginx['non_ssl_port']=80 Running reconfigure: chef-server-ctl reconfigure Starting Chef Client, version 12.0.3 resolving cookbooks for run list: ["private

How to query cookbook versions on a node?

老子叫甜甜 提交于 2019-12-09 08:04:04
问题 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

Best way to rename a file with chef

混江龙づ霸主 提交于 2019-12-08 18:44:53
问题 How can I rename a file with chef? In the chef doc I found only: create create_if_missing delete touch 回答1: Use ruby_block and inside use ::File.Rename(src,dst). Chef framework doesn't have file rename (or at least didn't had until 0.10.18). Just an example: ruby_block "Rename file" do block do ::File.rename(new_resource.src,new_resource.dst) end end 回答2: Another option if you need to rename multiple files. Checks one of the resource to know if it already ran. ruby_block "Rename file" do

home directory is not created with adding user resource with chef

大憨熊 提交于 2019-12-07 07:05:24
问题 On a vagrant box precise64 (ubuntu 12.04) While creating a user resource with Chef, the home directory is not created: My recipe: user "myuser" do supports :manage_home => true shell "/bin/bash" home "/home/myuser" comment "Created by Chef" password "myencryptedpassword" system true provider Chef::Provider::User::Useradd action :create end When I authenticate: $ su - myuser Password: No directory, logging in with HOME=/ Update - The workaround for precise64 (Ubuntu 12.04 64bit) directory "

Need to refactor to the new Ruby 1.9 hash syntax [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-07 04:11:26
问题 This question already has an answer here : Hash syntax in Ruby [duplicate] (1 answer) Closed 2 years ago . I have a recipe that has the following code that is failing a lint test: service 'apache' do supports :status => true, :restart => true, :reload => true end It fails with the error: Use the new Ruby 1.9 hash syntax. supports :status => true, :restart => true, :reload => true Not sure what the new syntax looks like... can anyone please assist? 回答1: In the Ruby version 1.9 has been

How to pass Chef data bag secret to a docker container?

眉间皱痕 提交于 2019-12-06 13:18:50
问题 I have already created a databag item which is existing on the chef server. Now, I am trying to pass on that databag item secret value to a docker container. I am creating the data bag as follows: knife data bag create bag_secrets bag_masterkey --secret-file C:\path\data_bag_secret I am retrieving value of that databag item in Chef recipe as follows: secret = Chef::EncryptedDataBagItem.load_secret("#{node['secret']}") masterkey = Chef::EncryptedDataBagItem.load("databag_secrets", "databag

cookbook_name in recipe- TypeError: no implicit conversion of Symbol into String

戏子无情 提交于 2019-12-06 10:09:59
I have the following code in my recipe but it errors. log "###" + cookbook_name + "::" + recipe_name + " " + Time.now.inspect + ": Starting execution phase" puts "###" + cookbook_name + "::" + recipe_name + " " + Time.now.inspect + ": Starting compile phase" The error is: TypeError: no implicit conversion of Symbol into String /test/chef/cookbooks/cookbook-server/recipes/setup_server.rb:10:in `+' The issue seems to be with the cookbook_name , recipe_name etc.(the ones which are not hardcoded). Please help. When you're doing + action with the strings in Ruby, it doesn't convert other types to

Notify service defined in included LWRP recipe

≯℡__Kan透↙ 提交于 2019-12-06 06:10:07
问题 Is there a way to notify a service to restart which is defined by an included LWRP? I wrote an LWRP called "sidekiq" which sets up a service, like this, and appears to be working fine on its own. service "#{new_resource.name}_sidekiq" do provider Chef::Provider::Service::Upstart action [ :enable ] subscribes :restart, "template[/etc/init/#{new_resource.name}_sidekiq.conf]", :immediately end The problem is I am using it another recipe which I use for deployments, and need it to notify the