GIT/tree installation by chef cookbook

Install git and tree by using chef cook book

Note:yum/apt-get are resources in chef


first need to deploy server or use the chef server online create account(only for less than 5 nodes)

download chef repo after adding organization details






Then go to chef-repo and create cook book using the below commands(CMD PROMPT)

C:\Users\admin>cd C:\Users\admin\Desktop\chef-repo\cookbooks

C:\Users\admin\Desktop\chef-repo\cookbooks>chef generate cookbook linuxyum -b
C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/ffi-1.12.1-x64-mingw32/lib/ffi/struct.rb:207:in `layout': [DEPRECATION] Struct layout is already d
efined for class Windows::ServiceStructs::SERVICE_STATUS_PROCESS. Redefinition as in C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/win32-service
-2.1.4/lib/win32/windows/structs.rb:72:in `' will be disallowed in ffi-2.0. (StructuredWarnings::StandardWarning)
Generating cookbook linuxyum
- Ensuring correct cookbook content

Your cookbook is ready. Type `cd linuxyum` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local --help` to see a full list of local testing commands.

Why not start by writing an InSpec test? Tests for the default recipe are stored at:

test/integration/default/default_test.rb

If you'd prefer to dive right in, the default recipe can be found at:

recipes/default.rb






then save this file and upload to chef server by using the berks

C:\Users\admin\Desktop\chef-repo\cookbooks>berks install
No Berksfile or Berksfile.lock found at 'C:/Users/admin/Desktop/chef-repo/cookbooks'!

C:\Users\admin\Desktop\chef-repo\cookbooks>ls
TESTINGFIRSTPROJECT  chefignore  linuxyum  starter

C:\Users\admin\Desktop\chef-repo\cookbooks>cd li*

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks install
Resolving cookbook dependencies...
Fetching 'linuxyum' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Using linuxyum (0.1.0) from source at .

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks upload
Uploaded linuxyum (0.1.0) to: 'https://api.chef.io/organizations/genpacts'

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>



Check  the cook book is uploaded in chef server then create runlist for the node(linux node)


After that we have to wait for convergence(default is 30mts),i dont want to wait and wanted to run the runlist manually

For that login to linux server and fire the below command

[ec2-user@ip-172-31-35-150 ~]$ sudo chef-client
Starting Chef Infra Client, version 15.8.23
resolving cookbooks for run list: ["linuxyum"]
Synchronizing Cookbooks:
  - linuxyum (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: linuxyum::default
  * yum_package[git] action install
    - install version 0:2.23.1-1.amzn2.0.1.x86_64 of package git
  * yum_package[tree] action install
    - install version 0:1.6.0-10.amzn2.0.1.x86_64 of package tree

Running handlers:
Running handlers complete
Chef Infra Client finished, 2/2 resources updated in 17 seconds
[ec2-user@ip-172-31-35-150 ~]$