Chef/knife environment configuration help

chefknife

I have the following as my knife.rb:

log_level                :info
log_location             STDOUT
node_name                'user'
client_key               '/home/user/.chef/user.pem'
validation_client_name   'chef-validator'
validation_key           '~/.chef/validation.pem'
chef_server_url          'url:4000'
cache_type               'BasicFile'
cache_options( :path => '/home/user/.chef/checksums' )
cookbook_path [ './', './site-cookbooks' ]

I can do "knife cookbook list" and all that fun stuff just fine, but when I go to edit I get:

# knife node edit test.domain.com -c knife.rb -e vim
ERROR: ArgumentError: Attribute chef_environment is not defined!

I have an environment set up:

# knife environment list
  _default
  production

and the node I'm trying to edit is on that environment. I have tried using the -E param, as well as adding an "environment" and "chef_environment" parameter to my knife.rb (the docs are a bit ambiguous as to which I should use), but to no avail. Anyone have any advice on this?

Best Answer

What version of Chef do you have installed on the local system where you're using Knife? What version is running on the Chef Server? (I presume that with a 'url:4000' chef_server_url you're running your own server instead of Opscode's).

You can get additional information out of knife with '-VV'.

knife node edit test.example.com -c knife.rb -e vim -VV

The setting in the knife.rb for the default environment to use is environment. On the node itself, chef_environment is a method to the Node object that returns the value of the node's environment and it is not an attribute.

Also, I'd recommend putting knife.rb in the .chef directory of your Chef Repository, or in your home directory. Knife will detect the configuration automatically by looking for .chef/knife.rb, similar to git.

Knife will also use the editor specified in the shell environment variable, EDITOR, too.

export EDITOR=`which vim`

Will have it use vim.

Related Topic