Install Chef and Create Cookbook with recipe | Deploy | Chef Tutorial

Опубликовано: 05 Май 2026
на канале: Aws tutorial for beginners With Devops
3,446
33

Chef Tutorial
#Chef Cookbooks
#Chef Devops
#Chef Books
#Ched Automation
#ChefTutorial
#DevopsChefTutorial

how to install chef workstation on ubuntu,how to install chef server,chef cookbook,chef cookbook create,chef cookbook example,chef cookbook tutorial,chef recipe example,chef recipe syntax,chef recipes devops,chef recipe to install apache,chef deploy cookbook,devops chef training videos,devops chef demo,chef devops tool

Now we are moving to Chef concept....


1.Let's install chef from chef official website
type this command "wget https://packages.chef.io/files/stable..."
2.Now install that package.
yum install chef-workstation/0.9.42/el/7/chef-workstation-0.9.42-1.el7.x86_64.rpm
3.Now check the version.
chef -v or chef --version
4.Chef successfully installed.
5.Now create the directory
"mkdir cookbooks"
6.Now go inside the cookbooks directory.
7.Now create a new cookbook name called test-cookbook
"chef generate cookbook test-cookbook"
8.Now check it whether it is created or not.
"tree test-cookbook"
9.We have to install the tree package
"yum install tree"
10.Now create one recipe inside test-cookbook
"chef generate recipe test-recipe"
11.Now open that test-recipe and add some content.
"vi test-cookbook/recipes/test-recipe.rb"
add this
file '/myfile' do
content 'hello my dear friend'
action :create
end

12.Now check that code is error free or not.
"chef exec ruby -c test-cookbook/recipes/test-recipe.rb"
13.Syntax ok....That means code is correct or valid.
14.Now apply that recipe locally
"sudo chef-client -zr "recipe[test-cookbook::test-recipe]"
15.With this code one file created with myfile with content (hello my dear friend).
16.To verify that file "ls /"

17.Now create and open second recipe.
"chef generate recipe demo-recipe"
we have to be inside the cookbook.
18.See one more recipe added.
19.Now add another content in that recipe.
"vi test-cookbook/recipes/demo-recipe.rb"
package 'tree' do
action :install
end

file '/myfile2' do
content "this is my second file"
action :create
owner 'root'
group 'root'
end

20.I am adding this code into new recipe called new-recipe.rb or mynew-recipe.rb
21.we must be outside cookbook. like this.
now run the vi command to edit.
vi test-cookbook/recipes/mynew-recipe.rb
22.Now apply the recipe locally (be inside the cookbook folder)
sudo chef-client -zr "recipe[test-cookbook::mynew-recipe]"
23.tree installation is up to date means we have already installed.
24.verify myfile2 created and tree also created.
ls /
which tree
25.Now we will create new Cookbook called apache-cookbook
"chef generate cookbook apache-cookbook"
26.Go inside the cookbook and create recipe called apache-recipe
"chef generate recipe apache-recipe"
27.now create one html file with content to display on webserver(ip address)
28.be inside apache-cookbook and run the below.
vi /apache-recipe.rb
package 'httpd' do
action :install
end

file '/var/www/html/index.html' do
content 'hello friends'
action :create
end

service 'httpd' do
action [:enable, :start]
end

29.apply that locally
sudo chef-client -zr "recipe[apache-cookbook::apache-recipe]"
30.Will check the syntax once.
chef exec ruby -c apache-cookbook/recipes/apache-recipe.rb
it is showing syntax ok.
ohh content now found in that apache-recipe.rb
will again add the content.

the code converted into
it is installed httpd service and then create a file with index.html
httpd chkconfig always on and service started.
30.Now will check the webserver working or not.
we have to use that ip address (ec2 instance) in web browser.
What ever we have given inside the html file it was executed...
thats'it
if you have any doubts regarding this comment and subscribe for more videos.
Thanks for watching...
These are the few main commands on chef

75 file '/var/www/html/index.html' do
76 content 'hello friends'
77 action :create
78 end
79 service 'httpd' do
80 action [:enable, :start]
81 end
82 vi /apache-cookbook/recipes/apache-recipe.rb
98 ls
99 cd apache-cookbook/
100 sudo chef-client -zr "recipe[apache-cookbook::apache-recipe]"
140 chef exec ruby -c apache-cookbook/recipes/apache-recipe.rb
141 sudo chef-client -zr "recipe[apache-cookbook::apache-recipe]"



Chef Server Roles - Add roles to Nodes | Chef automation tutorial
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
#Container #Coobook #chef knife #Devops tools #Devops
   • Chef Server Roles - Add roles to Nodes | C...  

Chef Installation - Bootstrap to Nodes | Automate Chef - Client (Cronjob)
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
#Container #Coobook #chef knife #Devops tools #Devops
   • Chef Tutorial - Bootstrap to Nodes Automat...  

Chef Intallation Error Fixed | Devops tutorial
   • Chef Tutorial -Chef Intallation Error Fixe...