Last active
January 8, 2017 01:47
-
-
Save gsmurali/1116363c1cae293bccc818d15f857df2 to your computer and use it in GitHub Desktop.
09 Linux Academy - Certified Chef Developer Basic Chef Fluency Badge- Lecture: Understanding Chef Cookbooks & Generating a Cookbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Cookbooks | |
+ A cookbook is the fundamental unit of configuration and policy distribution when using Chef | |
+ Cookbook contains | |
1. Recipes | |
1. Attribute Files | |
1. File distributions | |
1. Templates | |
1. Any extensions to Chef such as libraries and custom resources | |
+ Chef cookbook defines a scenario. For example, in case of an Apache cookbook | |
+ The cookbook defines everything needed to install and configure Apache | |
+ Modules and additional Apache configurations required for the application can be broken down into individual recipes within the cookbook. | |
+ README.md - located inside of cookbooks/cookbookname/README.md. Text to HTML conversion | |
+ metadata.rb - | |
Common Metadata settings | |
1. chef_version | |
1. depends (for include_recipe, cookbook dependencies) | |
1. version of the cookbook | |
#metadata.rb | |
name 'mycookbook' | |
maintainer 'The Authors' | |
maintainer_email '[email protected]' | |
license 'all_rights' | |
description 'Installs/Configures mycookbook' | |
long_description 'Installs/Configures mycookbook' | |
version '0.1.0' | |
depends 'mysql','>=1.0' | |
#Default cookbook recipe | |
+ default.rb | |
+ main part of the configuration for the cookbook generally lives here | |
#Generating a Cookbook | |
+ Terminal log | |
C:\Users\shinidharan\Documents\GitHub> ssh [email protected] | |
Warning: Permanently added '54.87.32.159' (ECDSA) to the list of known hosts. | |
[email protected]'s password: | |
Last login: Sun Jan 8 01:29:00 2017 from c-76-104-43-10.hsd1.va.comcast.net | |
[user@gsmurali1 ~]$ sudo su | |
[sudo] password for user: | |
[root@gsmurali1 user]# ls | |
chefdk-1.1.16-1.el7.x86_64.rpm Desktop learn.rb nodes VNCHOWTO xrdp-chansrv.log | |
[root@gsmurali1 user]# cd /root | |
[root@gsmurali1 ~]# ls | |
swap workstation | |
[root@gsmurali1 ~]# rm workstation/ | |
rm: cannot remove ‘workstation/’: Is a directory | |
[root@gsmurali1 ~]# rmdir workstation/ | |
rmdir: failed to remove ‘workstation/’: Directory not empty | |
[root@gsmurali1 ~]# cd workstation/ | |
[root@gsmurali1 workstation]# ls | |
Berksfile chefignore metadata.rb README.md recipes spec test | |
[root@gsmurali1 workstation]# cd recipes | |
[root@gsmurali1 recipes]# ls | |
default.rb | |
[root@gsmurali1 recipes]# cd .. | |
[root@gsmurali1 workstation]# cp /root/learn.rb recipes/ | |
cp: cannot stat ‘/root/learn.rb’: No such file or directory | |
[root@gsmurali1 workstation]# exit | |
exit | |
[user@gsmurali1 ~]$ ls | |
chefdk-1.1.16-1.el7.x86_64.rpm Desktop learn.rb nodes VNCHOWTO xrdp-chansrv.log | |
[user@gsmurali1 ~]$ pwd | |
/home/user | |
[user@gsmurali1 ~]$ sudo su | |
[root@gsmurali1 user]# ls | |
chefdk-1.1.16-1.el7.x86_64.rpm Desktop learn.rb nodes VNCHOWTO xrdp-chansrv.log | |
[root@gsmurali1 user]# cp learn.rb /root/workstation/recipes | |
[root@gsmurali1 user]# cd /root/workstation/ | |
[root@gsmurali1 workstation]# ls | |
Berksfile chefignore metadata.rb README.md recipes spec test | |
[root@gsmurali1 workstation]# cd recipes/ | |
[root@gsmurali1 recipes]# ls | |
default.rb learn.rb | |
[root@gsmurali1 recipes]# vim default.rb | |
[root@gsmurali1 recipes]# cd .. | |
[root@gsmurali1 workstation]# chef-client --local-mode recipes/default.rb | |
[2017-01-08T01:45:49+00:00] WARN: No config file found or specified on command line, using command line options. | |
[2017-01-08T01:45:49+00:00] WARN: No cookbooks directory found at or above current directory. Assuming /root/workstatio | |
n. | |
Starting Chef Client, version 12.17.44 | |
resolving cookbooks for run list: [] | |
Synchronizing Cookbooks: | |
Installing Cookbook Gems: | |
Compiling Cookbooks... | |
[2017-01-08T01:45:53+00:00] WARN: Node gsmurali1.mylabserver.com has an empty run list. | |
Converging 1 resources | |
Recipe: @recipe_files::/root/workstation/recipes/default.rb | |
* yum_package[tree] action install | |
- install version 1.6.0-10.el7 of package tree | |
Running handlers: | |
Running handlers complete | |
Chef Client finished, 1/1 resources updated in 11 seconds | |
[root@gsmurali1 workstation]# tree | |
. | |
├── Berksfile | |
├── chefignore | |
├── metadata.rb | |
├── nodes | |
│ └── gsmurali1.mylabserver.com.json | |
├── README.md | |
├── recipes | |
│ ├── default.rb | |
│ └── learn.rb | |
├── spec | |
│ ├── spec_helper.rb | |
│ └── unit | |
│ └── recipes | |
│ └── default_spec.rb | |
└── test | |
└── smoke | |
└── default | |
└── default_test.rb | |
8 directories, 10 files | |
[root@gsmurali1 workstation]# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment