Skip to content

Instantly share code, notes, and snippets.

@ericcalabretta
Last active July 6, 2020 16:29
Show Gist options
  • Save ericcalabretta/725fa1a72fab75c6cbfa301f6e3db4b3 to your computer and use it in GitHub Desktop.
Save ericcalabretta/725fa1a72fab75c6cbfa301f6e3db4b3 to your computer and use it in GitHub Desktop.
knife bootstrap example

Bootstrap chef client

To bootstrap a node we need to install install Chef-Client and configure Chef-Client to talk to Chef-Server. We can either use knife bootstrap or the validator bootstrap methods each with different stregths.

Knife Bootstrap

Requires SSH or winrm access to the node & access.

The nodes also need access to download.chef.io to download the chef-client.

You can customize this process for internal download repositories, proxies,etc but that's outside the scope of this walkthrough.

knife bootstrap FQDN/IP -N NodeNameGoesHere -U UserNameGoesHere -i ~/.ssh/id_rsa --sudo
knife bootstrap 34.223.50.203 -N centos -U centos -i ~/.ssh/id_rsa --sudo

knife bootstrap -o winrm FQDN/IP -N NodeNameGoesHere -U UserNameGoesHere -P PasswordGoesHere
knife bootstrap -o winrm 44.234.51.124 -N windows2019 -U administrator -P PasswordGoesHere

Validator Bootstrap

You'll need to be able to install chef-client & create a config file. This is a great method if you have security controls that'll require customization of knife bootstrap script.

This is also closer to how you may bootstrap chef-client using another tool like vRA, SCCM, Terraform, etc.

Download appropriate chef-client from https://downloads.chef.io/

Run the appropriate installer for your operating system. windows

Linux Example:

Create the chef-client config file at /etc/chef/client.rb & create the directory if it doesn't already exist.

Copy your organization validator key over to the /etc/chef directory. My example was demo-validator.pem

chef_server_url  "https://FQDN/organizations/orgname"
validation_key "/etc/chef/demo-validator.pem"
chef_license "accept"
ssl_verify_mode :verify_none

Windows Example

Create the chef-client config file at C:\chef\client.rb & create the directory if it doesn't already exist.

Copy your organization validator key over to the C:\chef directory. My example was demo-validator.pem

chef_server_url 'https://FQDN/organizations/orgname'
validation_key 'C:\\Users\\Administrator\\validator.pem'
chef_license 'accept'
ssl_verify_mode :verify_none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment