Chef cookbooks creating

 Creating a cookbooks

we should be in cookbooks path:
cd /opt/chef/chef-starter/chef-repo/cookbooks

Command to create cookbook:

chef generate cookbook cookbook1

when you create first cookbook , it will ask "License that need accepting" give yes

[root@chef-workstation chef-repo]# cd /opt/chef/chef-starter/chef-repo/cookbooks

[root@chef-workstation cookbooks]# chef generate cookbook cookbook1


+---------------------------------------------+

            Chef License Acceptance

Before you can continue, 1 product license

must be accepted. View the license at

https://www.chef.io/end-user-license-agreement/

License that need accepting:

  * Chef Workstation

Do you accept the 1 product license (yes/no)?

> Yes

Persisting 1 product license...

✔ 1 product license persisted.

+---------------------------------------------+

Generating cookbook cookbook1

- Ensuring correct cookbook content

- Committing cookbook files to git

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

There are several commands you can run to get started locally developing and testing your cookbook.

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

[root@chef-workstation cookbooks]# ls -lrt

total 4

-rw-r--r--. 1 root root 588 May  5 20:30 chefignore

drwxr-xr-x. 6 root root  88 May  6 09:21 starter

drwxr-xr-x. 6 root root 210 May  7 11:20 cookbook1

[root@chef-workstation cookbooks]#

Creating cookbook2

[root@chef-workstation cookbooks]# chef generate cookbook cookbook2

Generating cookbook cookbook2

- Ensuring correct cookbook content

- Committing cookbook files to git

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

There are several commands you can run to get started locally developing and testing your cookbook.

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

[root@chef-workstation cookbooks]# ls -lrt

total 4

-rw-r--r--. 1 root root 588 May  5 20:30 chefignore

drwxr-xr-x. 6 root root  88 May  6 09:21 starter

drwxr-xr-x. 6 root root 210 May  7 11:20 cookbook1

drwxr-xr-x. 6 root root 210 May  7 11:21 cookbook2

[root@chef-workstation cookbooks]# t



 Uploading to chef server

[root@chef-workstation cookbook1]# knife cookbook upload cookbook1
Uploading cookbook1      [0.1.0]
Uploaded 1 cookbook.
[root@chef-workstation cookbook1]#


Checking on the server :

In policy all cookbook will show


Add this cookbook to dedicated client server Node-1



Thanks 





Comments

Popular posts from this blog

To change the data directory location for PostgreSQL after installation

AWR

GIT