Bootstrap
* you will be prompted for a password otherwise pass flag -P <PASSWORD>
Common Error:
Knife bootstrap: ERROR: TypeError: can’t convert false into String
This happens when knife can’t find the .chef
directory in it’s current working directory, you should also be able to move to your ~/chef-repo
directory to get around this error.
SSH
For help type:
knife ssh –help
-a = attribute that’s not FQDN ( example is ipaddress )
-x = username to login with
-P = password
-E = environment
This will ssh with the attribute: ipaddress ( default is to use hostname ) with user “root” and password “none” and execute for all system with role “webserver”
$ knife ssh -a ipaddress -x root -P none ‘role:webserver’ ‘uptime’
‘name:host1*’ = query names that match host1*
‘uptime’ = command to run
The following would run chef client on all of your nodes
$ knife ssh ‘name:*’ ‘sudo chef-client’
The following would run chef client on all the nodes with the role “webapp”
$ knife ssh ‘role:webapp’ ‘sudo chef-client’
ssh to single node:
$ knife ssh ‘name:webserver01’ ‘sudo chef-client’
Run chef client on all nodes with role “webapp” in environment “dev”
$ knife ssh -E dev ‘role:webapp’ ‘sudo chef-client’
Node Information
Get all the attributes of a node
$ knife node show nodename -a node
Get all the attributes of a certain attribute group
* example is you have attributes in your attributes/default.rb like default[:whynot][:zoidberg] = “woopwoop”
$ knife node show nodename -a whynot