What is bootstrapping | Uploading cookbook in Chef-Server | Node Configurations

Apr 18 · 6 min read

Prerequisite: https://medium.com/nerd-for-tech/attributes-in-chef-a56073de90ea


Step-1: Access your Amazon EC-2 machine and follow the below command:

Ø sudo su

Ø cd cookbooks


Create an account of chef-server. Go to https://manage.chef.io/login, create an organization for your chef-server. After some time we will see “starter-kit” download it using this we can connect our chef-workstation with different nodes.

Start-kit contains all the server files which are used to connect over the server. Follow the below output sequentially.

First, Go to https://manage.chef.io/login> sign up, and verify your account

Second, create an organization, a pop-up dialogue will appear click on proceed.

The final chef-manage webpage will look like this

Third, Download starter-kit(server files) > unzip and using WinSCP software transfer it to a Linux EC-2 machine.

a. host name = value of public IPv4 DNS

b. User name = Linux instance username i.e. “ec2-user”

After that, click on the advance option > authentication and provide the key of the EC-2 Linux instance.

Click on OK > login and we will redirect to the WinSCP application. Let’s go to the directory where we have to unzip the starter kit. Drag and drop the “chef-repo” directory left to right means local machine to Linux server.

Fourth, Let’s Verify the file we shared in our Linux server.

To verify that our Linux workstation has been connected to the chef-server use the following command.

Ø Knife SSL check


Bootstrap a Node =>

Attaching a node to chef-server is called bootstrapping while the workstation and nodes are in the same availability zone.

Now, to connect chef-server to the node first redirect to the chef-repo directory where all server files are present.

First, Create an Ec-2 instance (chef-node-1)

Second, At the time of creating an instance, we downloaded a key-pair of the instance with a .pem extension in our windows local machine.

Use WinSCP machine to transfer it to our Linux workstation

Let's verify the key-pair in our Linux instance(Workstation)

Ø sudo su

Ø cd chef-repo

Ø ls

Third, Link the node with the workstation


Ø knife bootstrap — connection-user ec2-user — sudo -i Node-key.pem -N Node1


Now, There are two cookbooks in our workstation and we require only one cookbooks directory which currently exists in the “chef-repo” folder.

To move the existing cookbook to the chef-repo/cookbooks/ and delete the present cookbook i.e. cookbooks.


Ø ls

Ø ls cookbooks

Ø ls chef-repo/cookbooks

Ø mv cookbooks/test-cookbook chef-repo/cookbooks

Ø mv cookbooks/apache-cookbook chef-repo/cookbooks

Ø rm –rf cookbooks/


Let’s upload one of our cookbooks say “apache-cookbook” into chef-server


Ø knife cookbook upload apache-cookbook

Ø knife cookbook list

Second, How to add recipe to run_list of a particular node

Ø knife node run_list set Node1 “recipe[apache-cookbook::apache-recipe]”

To check existing recipes added to run_list

Ø knife node show <node_name>

Ø knife node show Node1

Third, To check this run_list graphically go to chef-server>Nodes> Node1> edit runlist.


In the above step, we have updated/uploaded the cookbook (apache-cookbook) to chef-server. Since here we are not using automation we will manually go to node (Node1) and run command chef-client. It will help to run the script which is added as a runlist.

Go to Node1 and follow the below command.

Ø Sudo su // root

Ø chef-client // run the recipe from parent chef-server

Now, let’s automate the process from workstation to chef-server to node/nodes

Let’s do some changes to our recipe (apache-recipe.rb) on our workstation.

Ø cd chef-repo

Ø vi cookbooks/apache-cookbook/recipes/apache-recipe.rb

Go to the node and try running the update runlist recipe. It will show output as up-to-date.

This means after modifying the script we have to upload it to the chef-server again.

If we upload the recipe to the chef-server and then try running it manually on the node, we can see the changes.




Now let’s automate the process. If we change in a script node will automatically call the chef-server and update it accordingly. Here we will use the crontab scheduler to automate the process.

Go to node1 and set the scheduler.

Ø Sudo su

Ø vi /etc/crontab


* * * * * root chef-client

// It means this command with root permissions will run every minute.

Come back to the workstation and do some modification to the recipe(apache-recipe.rb)

Also, the Modified recipe must be uploaded to the chef-server, and after that refresh it for a minute and we can see the node has called the chef server.

Ø knife cookbook upload apache-cookbook


[root@ip-172–31–13–9 cookbooks]# knife cookbook upload apache-cookbook

Uploading apache-cookbook [0.1.0]

Uploaded 1 cookbook.

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started


Written by

DevOps Engineer

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store