GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com
keywords: data_bags, roles, cookbooks, starter kit, chef supermarket,
---------
chef-apply ----->to create file
knif bootstrap ip -x root -p password -N nodename ---> to connect with the chef client server
chef-client -----> used to check in the client server
knif cookbook create ---> to create CB
knif cookbook test ----> to test cookbook
knif upload ---> to upload CBname chef server
knif cookbook list ---> it will list the available CB in the client server
in chef-repo-->.chef-->we have 2 files are 1. .pem and 2. knif.rb
when we download starter kit from cheff server it will generate cheff-repo dir in the cheff DK inside this we have .pem and knif.rb files to get connected with cheff server.
knif cookbook list ------> will show cookbook list in cheff DK
knif cookbook delete ------> will delete CB
==============================================================================================================================================================================
COOKBOOK Default.rb file
-------------------------------------
package "httpd" do
action :install
end
service "httpd" do
action :enable
end
service "httpd" do
action :start do
end
file '/var/www/html/index.html' do
content '
"Hello chef-client"
'
end
-----------------------------------------
kinf node run_list add "recipe[CBname]"
knif data bag create users -------> it will create users in data bags
knif data bag create group -------> it will create group in date bags
kinf data bag from file users user1.json -------> to move files from cheff DK to the cheff server
=============================================================================================================================================================================
JSON for creating users and group
----------------------------------
Users
-------
{
"id": "user1",
"comment": "devops user1",
"uid": 2000,
"gid": 0000,
"home": "/home/user1",
"shell": "/bin/bash"
}
Group
------
"id": "devops",
"gid": 3000,
"users": ["user1", "user2"]
}
==========================================================================================================================================
Searching for variables through CB
------------------------------------
search("users", "*:*").each do |user_data|
user user_data["id"] do
comment user_data["comment"]
uid user_data["uid"]
gid user_data["gid"]
home user_data["home"]
shell user_data["shell"]
end
end
include_recipe "users::groups" ----------->including users to the group
search for groups
------------------
search("groups", "*:*").each do |group_data|
groups group_data["id"] do
gid groups_data["gid"]
members group_data["members"]
end
end
============================================================================================================================================
-->in chef super market we will have cookbooks that we can download as per our requirement.