3

I want to write a chef cookbook to setup Linux desktop environments.

I created a kitchen by knife solo init chef-repo, and created a cookbook hello and a node file localhost.json.

Then I run:

$ knife solo cook localhost

and got this error:

Running Chef on localhost...
Checking Chef version...
ERROR: Network Error: Connection refused - connect(2) for "localhost" port 22
Check your knife configuration and network settings

Should I run a ssh daemon even if I use chef host and client in localhost?

I'm using Linux Mint 16 in a VirtualBox environments. And this is my ~/.chef/knife.rb config file:

log_level                :info
log_location             STDOUT
node_name                'ironsand'
client_key               '/home/ironsand/.chef/ironsand.pem'
validation_client_name   'chef-validator'
validation_key           '/etc/chef-server/chef-validator.pem'
chef_server_url          'https://vm-mint:443'
syntax_check_cache_path  '/home/ironsand/.chef/syntax_check_cache'
ironsand
  • 5,205

1 Answers1

2

You've tried to use knife-solo, a tool that is mean to "make working with chef-solo as powerful as chef-server". The underlying assumption is, as you found out, that you provision a different machine that you'll SSH into. Knife-solo will then install the chef-client via the omnibus packages (by default), put all the needed cookbooks onto the machine, and finally run chef-solo, from the Chef omnibus package:

From the docs: "knife solo cook uploads the current kitchen (Chef repo) to the target host and runs chef-solo on that host."

What you need to run chef-solo is, roughly:

  1. cookbooks (probably using Berkshelf and berks vendor (v3) or berks download (v2))
  2. a solo.rb configuration pointing to the cookbooks (see here)
  3. probably a JSON file for attribute overrides.

To manage localhost, it is enough to get that stuff together and run chef-solo -c solo.rb -J dna.json.

Bottom line: It's not necessary to use knife-solo to use Chef in localhost.

sr_
  • 15,384