chef-recipe

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

Installing rpm packages using chef (with dependencies)

女生的网名这么多〃 提交于 2019-12-11 11:08:11
问题 I have a list of rpm packages including dependencies. Locally I do rpm -i *.rpm and it works fine. How do I use the -i flag when I use chef's rpm_package resource. I cant use yum as we are trying something that works offline. Just need a chef way for rpm -i. 回答1: You have two options: Bash it Just like you did in your question, you can use the bash resource to execute the rpm command. This is not idempotent by default and is (obviously) not cross-platform: bash 'rpm -i *.rpm' do cwd '/path/to

multipart POST with Chef http_request resource

≯℡__Kan透↙ 提交于 2019-12-11 10:23:33
问题 Is there a way to do a multipart post with the Chef http_request resource? I have something like the following which posts the file contents, but I need to post form data along with it. http_request 'post_file_and_form_data' do headers ({'Content-Type' => 'multipart/form-data'}) url "http://myhost:2000/myapp/upload" action :post message lazy { ::File.read("/somewhere/myFile.yaml") } end 回答1: I'm not sure this is supported in the underlying Ruby standard library ( Net::HTTP ). I've seen most

How can I write a Chef provider that extends an existing provider?

泪湿孤枕 提交于 2019-12-11 06:46:08
问题 Cookbook A provides a LWRP that I would like to extend with a LWRP or HWRP in cookbook B, so that I could do something like the following, where provider_b would use the existing code/resources in provider_a and accept additional attributes it could use for it's own actions: provider_a "A" do attr_from_a :value end provider_b "B" do attr_from_a :value attr_from_b :value end Is this possible, and is it still possible if I want to avoid editing cookbook A? 回答1: It sounds like you're trying to

Detect the Chef Client version in a Chef recipe

故事扮演 提交于 2019-12-11 04:28:23
问题 I am upgrading my cookbooks from Chef version 12.11.18 to 13.6.4. Some version 13 specific instructions do not work in Chef version 12 and vice versa. My existing servers still use Chef Client 12, but the new servers will launch with Chef version 13 in the same environment, so the same cookbook version should work with both versions of Chef. I need to detect the version of the Chef Client in a recipe and select the version specific code with an "if" statement. How can I read the version of

How do I authenticate when I do a git clone with Chef? [duplicate]

一世执手 提交于 2019-12-10 21:56:27
问题 This question already has answers here : Git authentication in Chef (6 answers) Closed 5 years ago . I am new to all this but I am guessing I will be using SSH keys ... but how? git '/home/vagrant/foo' do repository 'me@repo.domain.com:/usr/git/app.git' reference 'master' action :sync user "vagrant" group "vagrant" end 回答1: Here what worked for me: 1 - Generate a SSH key pair (public + private) The public key you will add to your git repo 2 - Generate a key for encryption openssl rand -base64

How to find out version of software package installed on the node?

北城以北 提交于 2019-12-10 20:13:09
问题 I'm adapting Apache cookbook to work with 2.4 Apache. Opscode cookbook is currently failing because it's generating conf file with LockFile keyword that is excluded from the list of the Apache 2.4 keywords. I want to make a general solution, and populate my conf file depending on the version of software. To do so, I have to find out what's the version of already installed software. This same question has been bothering me for about a time now, but I've been managing to avoid it. Since I'm

413 Request Entity Too Large error occur while uploading cookbook

南楼画角 提交于 2019-12-10 19:12:06
问题 I found this error after i put a zip file into the cookbook and then uploaded it into the server. Can someone suggest me the right solution for this error... ERROR: Failed to upload ~/chef-repo/cookbooks/api/files/default/xx.zip (82c4bebb9890545ead67c44dca9f5a1f) to https://x.xxx.x.xxx:443/bookshelf/organization-9765dffbae2bea820ff192869963766f/checksum-82c4bebb9890545ead67c44dca9f5a1f?AWSAccessKeyId=970f9481256ced719247e5d4223442e56ac82b19&Expires=1519812888&Signature

How to get a full path of the running cookbook in the RightScale chef recipe?

那年仲夏 提交于 2019-12-10 15:53:32
问题 From inside my currently executing cookbook recipe I'd like to get access to it's "current" location on my executing machine. I need this to get access to it's cached directory structure. I have a feeling it's located somewhere inside "node[]" but I can't find any documentation about its structure at all. Any advise? Thanks 回答1: Just found the solution by inspecting the "run_context" instance: ruby_block "reload_client_config" do block do puts "HERE!!!!! -> " + run_context.cookbook_collection

Chef node - check if recipe will run on it, looking inside roles as well

南笙酒味 提交于 2019-12-10 14:59:55
问题 I want to find out if a specific recipe will be run on a node from inside a different recipe. I can node.recipe?(recipe_name) method, however some of my recipies are managed by roles and recipe? does not seem to look into the roles run list. Is there an easy way to find out if my recipie[redis] is going to be run on the current node? 回答1: You're looking for the recipes method. Note the trailing s ! So: node.recipes.include?(recipe_name) Also note that there is a similar pair of methods for