chef

Install a particular Ruby version using chef-run

允我心安 提交于 2019-12-11 19:06:40
问题 I have been trying to install a particular (latest) version of Ruby using Chef Workstation and its included chef-run CLI. This is the recipe I'm using for Ruby: package 'ruby' do version '2.5.3' action :install end Which, running with the command line chef-run -i /path-to/private_key user@host ruby.rb Produces the not very helpful message: [✔] Packaging cookbook... done! [✔] Generating local policyfile... exporting... done! [✖] Applying ruby from ruby.rb to target. └── [✖] [127.0.0.1] Failed

Reload environment variables PATH from chef recipes client

a 夏天 提交于 2019-12-11 18:42:46
问题 is it possible to reload $PATH from a chef recipe? Im intrsted in the response about process signals given in the following thread: How to have Chef reload global PATH I dont understand very well that example that the omribahumi user gives. I would like a clearer example with chef-client / recipe to understand, with that he explains, seems it is possible with that workaround. Thanks. 回答1: Well I see two reasons for this request: add something to the path for immediate execution => easy, just

Chef: reading attribute value from shell environment variables

会有一股神秘感。 提交于 2019-12-11 16:41:05
问题 I am trying to read value of an environment variable in attributes file of chef cookbook. Many posts have described that i can use ENV[] of ruby to achieve what i want. My attributes file looks something like this default['some_object']['some_attribute'] = ENV['SOME_ENV_VAR'] While running recipe, it seems to result in empty string. Any pointers? 回答1: assume that what you describe is the right way to do so (which is not), note that you need to set the environment variable on the node where

How to pull private git repo using chef from gitolite

帅比萌擦擦* 提交于 2019-12-11 16:01:37
问题 I am new to using chef. I am able to clone/pull a github repository using the following code on my recipe git "/var/www/hello_app" do repository "git://github.com/MyUser/MyProject.git" reference "master" action "sync" user "gituser" end I am trying to pull/clone my files from a private git repository managed my gitolite which means that authentication relies on sshd. I already have my id_rsa private key installed through a data_bag on gituser's .ssh/id_rsa file , the user who is pulling

chef, Could not find cookbook in your cookbook path

£可爱£侵袭症+ 提交于 2019-12-11 15:08:50
问题 in my chef-repo I added a cookbook cookbooks/mycookbook when i do $ knife cookbook upload mycookbook I get ERROR: Could not find cookbook php-1.3.1 in your cookbook path, skipping it Uploaded 0 cookbooks. What did I do wrong here 回答1: A config.rb file is used to specify configuration details for knife, which is loaded every time the knife executable is run and is located by default at ~/.chef/config.rb (and if i am not mistaken, you can also place it within the your chef repository directory

Chef-Server does not generate admin.pem

家住魔仙堡 提交于 2019-12-11 14:47:54
问题 I have used chef version 11 without any issues. Now that I hear the new version 12 is out, I wanted to use the same. So, on a fresh aws instance I downloaded the chef-server-core-12.0.0-1 installed it right away. Now going forward, I used the command, chef-server-ctl reconfigure to start all the services as mentioned in the official document. Now this step should also create a new admin, a validator that will be used in knife.rb . This was taken care of in the chef version 11. Now I am unable

How can you access Chef LWRP attributes in a recipe

左心房为你撑大大i 提交于 2019-12-11 13:48:54
问题 With some of the default chef resources, it is possible to access some of their attributes after they have been called # recipes/default.rb f = file "/tmp/file_resource" do owner "root" group "root" mode "0755" action :create end log "Path to my file is #{f.path}" # outputs "/tmp/file_resource" How can this be achieved in a custom LWRP (here is an example) # resources/default.rb actions :create default_action :create attribute :relative_path, :kind_of => String, :name_attribute => true

how to do 'knife client delete' and 'knife client create' using PyChef?

北城余情 提交于 2019-12-11 13:17:09
问题 What are the equivalent translations for: knife client delete notcool.my.com knife client create cool.my.com in PyChef? 回答1: from chef import autoconfigure, Client api = autoconfigure() Client.delete('notcool.my.com') Client.create('cool.my.com') 来源: https://stackoverflow.com/questions/26128891/how-to-do-knife-client-delete-and-knife-client-create-using-pychef

Chef Data Bags and dynamic variable passing

人走茶凉 提交于 2019-12-11 12:49:45
问题 I am trying to figure out a way to get the below code work; I have tried various methods but the chef-client run breaks at the 3rd line. lsf = "#{node[:env]}"+"_ls" dsf = "#{node[:env]}"+"_ds" dsTemplateBag = data_bag_item('configTemplates', "#{dsf}") lcTemplateBag = data_bag_item('configTemplates', "#{lsf}") However on another test recipe I was able to successfully get the following working: env = "test" dsTemplateBag = data_bag_item('configTemplates', "#{env}") I am quite new to Chef and

Chef LWRP - defs/resources execution order

别等时光非礼了梦想. 提交于 2019-12-11 12:33:07
问题 I have the following in a LWRP, all it does is exploding an .ear file:: action :expand do ear_folder = new_resource.target_folder temp_folder = "#{::File.join(ear_folder, 'tmp_folder')}" expand_ear(new_resource.source, ear_folder) expand_wars(ear_folder,temp_folder) end def expand_ear(src,dest) bash "unzip EAR" do cwd dest code <<-EOF pwd ls -l jar -xvf #{src} EOF end end def explode_wars(src,dest) Dir.glob("#{basepath}/*.war") do |file| ......... ###crete tmp folder, move .war there then