6

I've read the documentation on Chef twice over. I still can't wrap my head around it's concept because they skip but fundamentals and jump to complex deployments with chef-server.

Using chef-solo and possibly knife, is there a simple way to provision a server and deploy?

I may be wrong, but it seems like with my cookbooks prepped, this should be very simple.

knife rackspace server create --flavor 1 --image 112

That provisions my server. I can optionally pass --run-list "recipe[mything]", but how do my cookbooks in ~/my_cookbooks actually get on the server? Do I have to manually transfer them? That seems counterproductive.

  • 1
    You mean _one_ server? Don't you think that this is as taking a sledgehammer to crack a nut. Chef is meant to deploy dozens, hundreds and thousands, but not one. – mailq Dec 13 '11 at 21:57
  • 4
    Yea that is true. But I'm using Vagrant to distribute a VM for local development. That VM is built with Chef. Why would I manually deploy something to the cloud that i've already automated with chef for a local VM? – Andrew McCloud Dec 14 '11 at 00:30
  • @mailq Chef is meant to manage any number of servers that you want to manage. If you have small/modest needs, Opscode Hosted Chef is a free Chef Server that Opscode runs as a service. You can of course also use Chef Solo if that's your thing. – jtimberman Dec 22 '11 at 23:24
  • I disagree with mailq. Configuration Management is for managing one server, and also for managing 100,000. – Tom O'Connor Nov 19 '12 at 17:26
  • My answer below might shed some light on this question - http://serverfault.com/questions/340603/bare-minimal-chef-provisioning-and-deployment/#answer-461302 – Brian Dec 28 '12 at 00:02

5 Answers5

6

If you use chef-solo, you don't get to use knife. Knife is API client for the chef-server, with some extra utility sugar (like knife rackspace server create you've mentioned).

To configure server with chef-solo, you should copy your chef repo to the server, and run chef-solo there over ssh. There is no ready-made script or knife plugin that I know of that would do it automatically.

Command knife rackspace server create creates new Rackspace server, and then initializes it for chef-server that knife knows of by calling knife bootstrap. It won't work with chef-solo easily.

Technically, knife bootstrap, and thus knife rackspace server create, can be coerced to work with chef-solo by writing a custom bootstrap template that, instead of initializing chef-client, would download your chef repository and run chef-solo - see knife bootstrap --help, its wiki page, or source for details. You can see example templates for installing chef-client here. This is an advanced feature, though, and it's not very well documented.

If you don't want to handle complexity of installing and managing your own chef-server, you can use free layer of Opscode's Hosted Chef, which is Chef-server SAAS offering and is free up to three nodes. I'd recommend starting any serious work with server anyway - chef-solo is as good as a decent bootstrap shell script, no more, and you're missing out on many important/interesting features like search and data bags, which allow you to configure your servers in a data-driven way.

  • 2
    To clarify, chef-solo users *can* use knife, just not all the sub-commands that come with it by default. Specifically, the sub-commands that operate with a Chef Server :-). – jtimberman Dec 27 '11 at 07:39
5

Check out the knife-solo plugin, which can automatically install chef-solo on your remote server, upload your cookbooks onto it, and then run chef-solo. It basically automates what other folks who've answered this question have suggested doing.

Kief
  • 301
  • 3
  • 3
2

Before each chef-solo run, the cookbooks should be present on that target machine, either by transferring it (via ftp/scp) or pointing the cookbook_path to a network share .

If you want the cookbooks to be automatically downloaded, you would need to run a Chef Server. Whether you want to run your own chef server, or use a hosted one from OpsCode is up to you, but it is needed.

Nick Josevski
  • 163
  • 2
  • 5
Shyam Sundar C S
  • 1,063
  • 8
  • 12
1

Barest, most basic way to get going with chef-solo.

Examples are contrived, and you should modify them.

More information about Chef Solo:

While Chef Solo is useful, it is really a limited way to use Chef. It doesn't expose information about the node outside of the node itself, so it cannot be used for dynamic discovery or data-driven infrastructure management nearly as easily as with Chef Server.

jtimberman
  • 7,511
  • 2
  • 33
  • 42
0

There's a git project for that ;)

The knife-solo git project should enable you to run knife in conjunction with chef-solo and allow you to do remote provisioning from your local dev environment to remote servers like this once you've got it configured locally and installed:

knife solo cook ubuntu@10.0.0.201

Brian
  • 109
  • 3