chef

how to set node attribute value from execute resouce command output

放肆的年华 提交于 2020-01-16 19:19:08
问题 execute 'my_commad' do command 'myvar=`curl http://example.com/blah/blah` && echo -n $myvar > /etc/value' end node.default[:attribute1] = ::File.read('/etc/value').chomp This will fail, because at the time of convergence the node attributes are checked first and hence it will throw the following error: ERROR: No such file or directory @ rb_sysopen - /etc/value 回答1: if you are setting the node attribute at the recipe itself and not in an attribute file, this might work for you. though, in my

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

“mv” resource in chef

不羁的心 提交于 2020-01-16 12:04:32
问题 when am executing the below recipe am getting the error message. My requirement is I need to "Move" only certain folders(log,tmp)from source to some other location only whenever folders are available in source, if not no need to move and successfully execute my resource. whenever am executing the below resource first time with source folders(log,tmp) it will execute successfully but when to run the same resource second time it throws error message because there are no folders(log,tmp) in

“mv” resource in chef

梦想的初衷 提交于 2020-01-16 12:03:17
问题 when am executing the below recipe am getting the error message. My requirement is I need to "Move" only certain folders(log,tmp)from source to some other location only whenever folders are available in source, if not no need to move and successfully execute my resource. whenever am executing the below resource first time with source folders(log,tmp) it will execute successfully but when to run the same resource second time it throws error message because there are no folders(log,tmp) in

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

Installing a Particular Library Version

蹲街弑〆低调 提交于 2020-01-16 00:55:10
问题 Using vagrant-berkshelf with the Maven and Tomcat cookbooks, I can specify a major version to install. Example: Maven - 2 or 3 Tomcat - 5 or 6 If I want to specify an exact version of a library (Maven 3.2.1), should I just use the Ark Cookbook to install the desired version? Having limited DevOps experience, I'm used to making use of yum or apt-get to manage my libraries without specifying a particular version. 回答1: The Maven cookbook already uses ark. So you could just override the following

What's the meaning of 'Last Check-in'?

a 夏天 提交于 2020-01-15 20:27:18
问题 When looking at the status tab in the chef server webgui I see some of my nodes have a last check-in of a few minutes ago, even though I haven't ran chef-client in them for days. Does that mean chef-client is running by itself in some nodes? Thanks 回答1: It's the last time a "node" (server) sent information to the Chef Server. It's like a healthcheck. 回答2: This isn't quite on topic, but it supports some responses I have seen in this post: You can always add the Chef community "chef-client"

What's the meaning of 'Last Check-in'?

别等时光非礼了梦想. 提交于 2020-01-15 20:26:41
问题 When looking at the status tab in the chef server webgui I see some of my nodes have a last check-in of a few minutes ago, even though I haven't ran chef-client in them for days. Does that mean chef-client is running by itself in some nodes? Thanks 回答1: It's the last time a "node" (server) sent information to the Chef Server. It's like a healthcheck. 回答2: This isn't quite on topic, but it supports some responses I have seen in this post: You can always add the Chef community "chef-client"

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