Bootstrap (add node) localhost in chef

chef

Problem. Following command line

knife bootstrap 127.0.0.1 -r 'recipe[chef-client]' -x user -p password --sudo

returns

Bootstrapping Chef on 127.0.0.1
WARNING: Failed to connect to 127.0.0.1 -- Errno::ECONNREFUSED: Connection refused - connect(2)

Expected that this command will succeed and after it

knife node list

will return

[
"127.0.0.1"
]

SSH server is working fine on localhost and ssh user@127.0.0.1 -p password works as expected.

Best Answer

Looks like the problem with the invocation is that you specified the password with the -p option, which knife bootstrap uses to specify an alternate ssh port. You wanted to use the -P (capital P), which the right option for specifying the password to the bootstrap command.

And, as Justin has indicated, bootstrap is likely not technically necessary if you already have chef installed to the point where you can run 'knife' commands. You should be able to fire off a 'chef-client' to enroll your node to the server (perhaps needing the validation key with -K option, if it's not already installed/available in /etc/chef). Once registered to your server, you can issue knife node run_list add commands to add the appropriate roles/recipes to the runlist, then invoke another chef-client to get it to take effect. Then again, bootstrap does it all in one command, so it's not a terrible option.

Related Topic