Chef Server Roles - Add roles to Nodes | Chef Commands | Chef Tutorial

Опубликовано: 03 Май 2026
на канале: Aws tutorial for beginners With Devops
815
8

Chef Server Roles - Add roles to Nodes | Chef Commands | Chef Tutorial
#ChefTutorial
#Chefbooks
#Chef cookbooks
#Chef Automation
#Chef Devops

Now will discuss with roles in chef...

with this we will save lot of effort in case of if we have hunderds & thousands
of nodes...

Instead of adding cookbook to the each and every node will attach roles to the
nodes.

let's seee...

1.I have setup one workstation with chef server
2.Launched 2 nodes.
3.Now will add roles to the nodes.
name "web"
description "web server role"
run_list "recipe[apache-cookbook::apache-recipe]"

i will create the cookbook and recipe after editing the role.

4.Now bootstrap those nodes to server.
knife bootstrap ip --ssh-user ec2-user --sudo -i chef.pem -N node1
knife bootstrap ip --ssh-user ec2-user --sudo -i chef.pem -N node2
5.Now upload the roles to chef server.
knife role from file roles/web.rb
6.Now attach role to all nodes
knife node run_list set node1 "role[web]"
knife node run_list set node2 "role[web]"
7.Now upload cookbook to the chef server.
ohh cookbook recipe has error let's fix it.

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

8.Now will paste the public ip and see..both nodes also...
We have to apply that recipe to the server locally.

sudo chef-client -zr "recipe[apache-cookbook::apache-recipe]"

Main workstation got the webserver.will wait for 1 min for nodes.
all are working fine now...will modify the content once...
Modify again will see...one more time.

That means after creating roles and adding runlist there....

each time we modify we have to upload that cookbook and then just
run chef-client...(if you want on base workstation web server update)
otherwise only upload cookbook to the server is enough...

that's it friends...

Let's subscribe for more updates...

now will see how to remove/delete all the nodes and coobooks

1.To delete cookbooks from chef server
knife cookbook delete cookbook-name

2.To see list of nodes present in chef server
knide node list

3.To delete nodes from chef server
knife node delete nodename

4.To see list of clients present in chef server
knife client list

6.To delete clients from chef server
knife client delete clientname

7.To see list of roles present in chef server
knife role list

8.To delete roles from chef server.
knife role delete rolename

#ChefTutorial
#Chefbooks
#Chef cookbooks
#Chef Automation
#Chef Devops

Chef Server Roles - Add roles to Nodes | Chef delete commands | Chef automation tutorial
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
   • Chef Server Roles - Add roles to Nodes | C...  

Chef Server Installation - Bootstrap to Nodes | SSH Errors fixed | Automate Chef - Client (Cronjob)
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
   • Chef Tutorial - Bootstrap to Nodes Automat...  

Chef Intallation Error Fixed | AWS Tutorial For Beginners with Devops | Devops tutorial
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
   • Chef Tutorial -Chef Intallation Error Fixe...  

Ohai Commands, Create User & Group | Run All Cookbook Recipes at a time | Chef Tutorial Part - 2
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
   • Create User Group | Run All Cookbook Recip...  

Install Chef and Create Cookbook with recipe | Deploying Apache Web server | Devops Chef Tutorial
#Chef #Chef Tutorial For Beginners #Chef books #Chef Devops #Chef automation
   • Install Chef and Create Cookbook with reci...