Writing cookbooks
Cookbooks has attributes, recipes, templates etc
Using Community cookbooks
- Modify Berksfile in the cookbook by adding cookbook name, say, cookbook 'yum-centos', '~> 3.0.0'
- Modify metadata.rb in cookbook by updating dependencies, say, depends 'yum-centos', '~> 3.0.0'
- Execute below commands
$ berks installPrerequisites
$ berks upload
Make sure we have below configs/files
- Chef cookbook
- Chef Environment
- Chef Role
- Install vagrant from https://www.vagrantup.com/downloads.html
- Install Virtualbox
- Modify .kitchen.yml file referring to community cookbook recipe to test locally.
- Goto cookbook directory and execute kitchen commands to build, list, login to new created resource from chef cookbooks.
$ kitchen convergeUpdate authentication key
$ kitchen list
$ kitchen login
# Connect to chef server
[pd@ip-disects ~]$ ssh -A -t SSH_SERVER_IP
# Following commands are executed on chef server
[pd@ip-disects ~]$ sudo chef-server-ctl user-create praveend Praveen Darshanam praveend@chef.io Myp@ssw0rd -f /tmp/praveend.key
ERROR: Conflict
Response: Username or email address already in use.
[pd@ip-disects ~]$ sudo chef-server-ctl user-delete praveend
Do you want to delete the user praveend? (Y/N) y
Checking organization memberships...
Checking admin group memberships for 1 org(s).
FATAL: praveend is in the 'admins' group of the following organization(s):
- disects
Run this command again with the --remove-from-admin-groups option to remove the user from these admin group(s) automatically.
Run this command again with the --remove-from-admin-groups option to remove the user from these admin group(s) automatically.
[pd@ip-disects ~]$ sudo chef-server-ctl user-delete praveend --remove-from-admin-groups
Do you want to delete the user praveend? (Y/N) y
Checking organization memberships...
Checking admin group memberships for 1 org(s).
Removing praveend from admins group of 'disects'
Deleting user praveend.
[pd@ip-disects ~]$ sudo chef-server-ctl user-create praveend Praveen Darshanam praveend@chef.io Myp@ssw0rd -f /tmp/praveend.key
[pd@ip-disects ~]$ sudo chef-server-ctl org-user-add disects praveend --admin
User praveend is added to admins and billing-admins group
Upload working cookbook to chef server after local testing. Test the cookbook on a cluster node to make sure everything is working fine, this needs some experience though.
Upload working cookbook to chef server after local testing. Test the cookbook on a cluster node to make sure everything is working fine, this needs some experience though.
$ knife cookbook upload cookbook_name