chef-recipe

How to check which java version is installed

喜你入骨 提交于 2020-07-23 08:06:38
问题 The chef client already has java installed on it. How can I check which version of java is installed using chef. I know I can write a small ohai plugin to do the same but is there any other way to check which java version is installed on the client? The java installation is not an rpm installation though on some endpoints it might be an rpm installation. 回答1: We already attempt to query it in Ohai for you: https://github.com/chef/ohai/blob/master/lib/ohai/plugins/java.rb However this is

How to check which java version is installed

跟風遠走 提交于 2020-07-23 08:06:28
问题 The chef client already has java installed on it. How can I check which version of java is installed using chef. I know I can write a small ohai plugin to do the same but is there any other way to check which java version is installed on the client? The java installation is not an rpm installation though on some endpoints it might be an rpm installation. 回答1: We already attempt to query it in Ohai for you: https://github.com/chef/ohai/blob/master/lib/ohai/plugins/java.rb However this is

How to check which java version is installed

人走茶凉 提交于 2020-07-23 08:04:20
问题 The chef client already has java installed on it. How can I check which version of java is installed using chef. I know I can write a small ohai plugin to do the same but is there any other way to check which java version is installed on the client? The java installation is not an rpm installation though on some endpoints it might be an rpm installation. 回答1: We already attempt to query it in Ohai for you: https://github.com/chef/ohai/blob/master/lib/ohai/plugins/java.rb However this is

Should I use include_recipe or add the recipe to run_list?

旧时模样 提交于 2020-01-30 14:18:28
问题 Trying to figure out the best approach for a large project. When is it appropriate to add recipes within a recipe by using include_recipe as opposed to adding the recipe to the run_list ? Is there a good rule of thumb? 回答1: As I see it, any recipe should be able to run on an empty machine on its own. So if some recipe A depends on recipe B run before it, I always use include_recipe. For example: 2 cookbooks, tomcat and java. Tomcat requires java. When some user wants to install tomcat, he may

How can I loop through bash routine in Chef?

别说谁变了你拦得住时间么 提交于 2020-01-26 04:09:05
问题 I have a bash script in Chef that fetches the time through NTP protocol from 3 instances running NTP server. The code at present is if not node.run_list.roles.include?("ntp_server") bash "ntpdate" do code <<-EOH /usr/sbin/ntpdate -s 10.204.255.15 10.204.251.41 10.204.251.21 EOH end end This has been working just fine. However, I am supposed to automate the task such as if one of the instances is replaced, there is no manual intervention required to update the IP in the code above. To achieve

Overriding role attributes in chef-client with packer

风流意气都作罢 提交于 2020-01-16 17:19:02
问题 I have a chef role: { "name": "my-role", "description": "Defines a role", "override_attributes": { "cookbook_one" { "key": "value" } } "run_list": [ recipe["cookbook_one"], recipe["cookbook_two"] ] } Which I call with Packer in the provisioner block: { "variables": { "my-variable": "" }, "provisioners": [ { "type": "chef-client", "server_url": "https://mychefserver.com/", "run_list": "role[my-role]", ... } I need to be able to add some attributes to recipe_two from within Packer. I read I can

Passing an integer value through a node attribute in chef

南楼画角 提交于 2020-01-16 09:05:13
问题 I am new to chef. Please let me know how can I pass an integer value as a node attribute (chef-client -j). Tried with json input, but I was not able to convert the hash value into an integer. For example : If I am passing my -j count:"1" , I need to the output node['count'] in integer value and not in hash. Can someone help me in converting it into integer value in Chef or is there any other way I can send my integer input to the chef? 回答1: you can provide any (primitive) node attribute in

Chef Decryption of Data Bags and Retrieval of Key

[亡魂溺海] 提交于 2020-01-15 16:39:21
问题 I am using an encrypted data bag to encrypt an ssh key and decrypted it via Chef. The data bag had an id of pwind_ssh_rsa_pub_cred, but what I really want is the unencrypted data for the ssh key. I want to then take the key and append it to a file, but the code that I have currently is running into some issues. With static values, the below code works. Additionally, I am a big confused as to what the type is of "decrypted_ssh". ruby_block "obtainCredentials" do block do hadoop_key = Chef:

How to use Chef PHP cookbook to install version higher than 5.3.3 [closed]

拥有回忆 提交于 2020-01-15 07:18:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am using the Opscode community PHP cookbook to install PHP on a node. The node is CentOS and I have attempted setting the install_method to "source" and also tried overriding the version in my Role file. No matter what I do - Chef continues to install PHP 5.3.3. I want to know how to use this cookbook to

How do I get log output in test kitchen?

馋奶兔 提交于 2020-01-14 03:50:10
问题 I have this in my recipe: log mylog1 do level :info message 'WHY I NO SEE THIS?' end log mylog2 do level :info message 'WHY I NO SEE THIS?' end This is what I see when doing kitchen converge -l debug : ... Converging 3 resources Recipe: mybook::myrecipe * log[mylog1] action write * log[mylog1] action write ... 回答1: There are two parts of this question: First, The log level passed to kitchen with "-l debug" is for the kitchen executable and not for the provisioner , in this case " chef-solo ".