how to use chef to build server through ruby code
Hi, I’m looking at chef for a new SaaS project and can see how to create a new server with knife. But is there a way to do this through ruby?
we have a ruby server that needs to periodically create new servers. While we can use the fog library to create the actual server on EC2, its not clear how to install the chef-client. knife can do this but its not clear that knife has an interface/api that ruby code can call. I guess my code could run knife as a shell command but I’m hoping for something a bit more elegant.
thanks in advance
Is there some way to specify ssh user in the knife.rb file itself rather than on the cmd line?
Based on what I see in the source (https://github.com/opscode/knife-ec2/blob/master/lib/chef/knife/ec2_server_create.rb) :
I can’t think of single way of specifying a value for ssh_user inside the knife.rb file and not on the command line. Am I right about this? Or can someone illuminate me with some syntax I’m missing? So far I used trial & error to test the following but they didn’t get picked up:
Knife ssh not work when a node is not bootstrapped
I have a node which is registered to chef server when its first time run the chef-client, so I can see the node in the web interface.
But I can’t run knife ssh to it, return error
So, in this case, what is the best way to copy the ssh key?
Call knife commands from a Ruby script without shelling out
(Also asked on StackOverflow.com)
I’ve inherited some shell scripts that are helpful for setting up our application environment using Chef and knife. That’s nice.
But what I’d really like to do is have the power and flexibility of a Ruby script to do the same thing.
If I shell out to knife I lose the real time output of the command.
It seems like I should be able to call all of knife’s functionality from within Ruby by including the ‘chef’ gem and maybe the ‘cloudstack-fog’ plug-in I use.
But I haven’t found any examples or API documentation. Trying to dig through the chef gem source is an exercise in frustration.
Shouldn’t I be able to do the equivalent of a knife cloudstack server create -E … etc. from a Ruby script?
knife bootstrap fails ssh authentication on centos 6
I am bootstrapping a vm using knife which works on CentOS 5.4 but fails on CentOS 6.2 when attempting to ssh onto the node with “ERROR: all authorization methods failed (tried publickey, password)”
I can ssh onto the vm, why can’t knife? Anyone else seen this issue?
knife cs server create test-centos-6 -N test-centos-6 -d chef-full -r “role[base],role[cs_server]” -x <user> -P <pword> —no-public-ip -T “CentOS 6.2 x64 LAMP Stack” -VV
Bootstrapping Chef on 10.110.66.244
DEBUG: Adding 10.110.66.244
DEBUG: establishing connection to 10.110.66.244:22
DEBUG: connection established
INFO: negotiating protocol version
DEBUG: remote is
How to execute a node' runlist?
But the problem is: How can I request the node to execute the runlist from the webUI? Seems there is no way to do so?
Also the knife command is not able to do that? http://wiki.opscode.com/display/chef/Managing+Nodes+With+Knife
Can't unzip cookbooks on Windows Command Line - 'tar' not recognized
When I try
I get an error. The file does not unzip and I am left with a .tar.gz file ONLY. Any ideas?
The error message:
Thanks in advance.
"knife prepare/cook" through ssh gateway
Hi, I try to cook via knife (solo) a server, which is only reachable through another one. <local machine> —> <ssh gateway/proxy/tunnel> —> <target server> It seems to be possible to configure a ssh gateway for bootstrapping but I couldn’t find an equivalent for “knife prepare” and “knife cook”. Is this supported/possible?
'knife openstack server create' failing
The command I am running looks like this:
The error I am getting is:
My knife.rb looks like this:
Running ‘knife client list’ returns ok so I think Chef workstation is setup correctly. Running ‘knife openstack server list’ returns ok so I think the knife-openstack plugin is setup correctly.
The versions I am using are: Chef: 10.16.2 knife-openstack: 0.6.2 Openstack: Essex
I have followed the chef workstation setup here: http://wiki.opscode.com/display/chef/Workstation+Setup+for+Debian+and+Ubuntu
I have also followed the openstack plugin instructions here: https://github.com/opscode/knife-openstack/blob/master/README.md
No amount of tweaking with the workstation setup or knife-openstack command params seems to make a difference.
Thanks in advance, Paul.