A Chef node is a physical or virtual machine with an operating system that is connected to the Chef server. Once the node has made the connection to the Chef server, the installed Chef Client can execute Chef cookbooks to configure the machine.
Bootstrapping is the process to connect the node the first time to the Chef server, or to attach it again if the node lost the connectivity to the Chef server. To be able to bootstrap a node, your workstation needs to have the Chef Development Kit installed. The kit includes the ‘knife’ command that communicates with the Chef server. Your workstation also has to be able to connect to the Chef server with the YOUR_USERNAME.pem file you store in the .chef directory just above your cookbooks.
Bootstrap a Linux node
To bootstrap a Linux node, open a terminal window on your workstation and execute the command:
With password authentication ----------------------------- knife bootstrap MY_NODE_IP -x SERVER_ADMIN_USERNAME -P SERVER_ADMIN_PASSWORD --sudo --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]' --json-attributes '{"MY_ATTRIB1":"MY_VALUE1","MY_ATTRIB2":"MY_VALUE2"}' With key authentication ----------------------- knife bootstrap MY_NODE_IP -x SERVER_ADMIN_USERNAME -i PATH_TO_KEY_FILE --sudo --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]' --json-attributes '{"MY_ATTRIB1":"MY_VALUE1","MY_ATTRIB2":"MY_VALUE2"}'
Bootstrap a Windows node
knife bootstrap windows winrm MY_NODE_IP -x SERVER_ADMIN_USERNAME -P SERVER_ADMIN_PASSWORD --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]' --json-attributes '{"MY_ATTRIB1":"MY_VALUE1","MY_ATTRIB2":"MY_VALUE2"}' -V
where
- MY_NODE_IP is the IP address of the node you want to attach to the Chef server,
- SERVER_ADMIN_USERNAME and SERVER_ADMIN_PASSWORD are the credentials to connect to the node.
If the Windows server is in the Windows domain start the username with the domain name MY_DOMAIN\\SERVER_ADMIN_USERNAME
If the Windows server is not in the domain start the username with the IP address MY_NODE_IP\\SERVER_ADMIN_USERNAME - THE_NODE_NAME is the unique name you want the node to use in the Chef server database. If you are bootstrapping a server that lost connectivity to the Chef server or moving the node to another Chef server, find the node name in the node list.
- THE_ENVIRONMENT is the name of the environment the node will run the cookbook in,
- The run list is a list of cookbooks and roles. No spaces are allowed in the string.
Troubleshooting
If the known_hosts file already contains an entry for a different server with the same IP address, we get the error message
ERROR: Net::SSH::HostKeyMismatch: fingerprint … does not match for “…”
Open the ~/.ssh/known_hosts file and delete the line that contains the IP address of the server.