Multiple Resources in Chef

Share via:

Multiple Resources in Chef

Dear Readers,

In this article,we will see Multiple Resources in Chef.
we can create multiple resource at once and convert the code to infrastructure in nodes.
I am going to install multiple packages,create multiple file and directories,groups and users in 2 nodes by run single command (chef-client).

Steps to Follow

  1. Open your workstation Linux terminal through putty.
  2. Switch to root user.
  3. Go to chef-repo.
  4. Create a new cookbook “ktexperts-multi-resources” inside chef-repo/cookbooks.
  5. Create a new recipe “ktexperts-multi-resources” inside the cookbook “ktexperts-multi-resources”.
  6. Go to chef-repo directory.
  7. Modify role “ktexperts-web.rb”.
  8. Upload role to chef server.
  9. Verify run list of Node 1 “chef-Node-1”.
  10. Verify run list of Node 2 “chef-Node-2”.
  11. Open the recipe “ktexperts-multi-resources.rb” and write to create multiple resources.
  12. Upload cookbook “ktexperts-multi-resources.rb” to chef server.
  13. Go inside the Node 1 “Chef-Node-1” and Verify all resources.
  14. Go inside the Node 1 “Chef-Node-2” and Verify all resources

1. Open your workstation Linux terminal through putty

2. Switch to root user

3. Go to chef-repo 

4. Create a new cookbook “ktexperts-multi-resources” inside chef-repo/cookbooks

Go to cookbooks

Using below command to create cookbook

Verify the list of components of the cookbook “ktexperts-multi-resources”

5. Create a new recipe “ktexperts-multi-resources” inside the cookbook “ktexperts-multi-resources”

Go to cookbook “ktexperts-multi-resources”

Run below command to create a new recipe 

Verify recipes inside the cookbook

6. Go to chef-repo directory

7. Modify role “ktexperts-web.rb” 

8. Upload role to chef server

To see the list of Nodes

[root@ip-172-31-42-243 chef-repo]# knife node list

9. Verify run list of Node 1 “chef-Node-1”

10. Verify run list of Node 2 “chef-Node-2”

11. Open the recipe “ktexperts-multi-resources.rb” and write to create multiple resources

12. Upload cookbook “ktexperts-multi-resources.rb” to chef server

Verify cookbooks

To see the list of cookbooks

13. Go inside the Node 1 “Chef-Node-1” and Verify all resources

Connect Node 1 “Chef-Node-1” Linux Terminal through Putty

Switch to root user

Verify Packages

Verify Users

Verify files and directories

Verify groups

Verify package 

14. Go inside the Node 2 “Chef-Node-2” and Verify all resources

Connect Node 1 “Chef-Node-2” Linux Terminal through Putty

Switch to root user

Verify Packages

[root@ip-172-31-4-151 ec2-user]# which tree

Verify Users

[root@ip-172-31-4-151 ec2-user]# tail -3 /etc/passwd

Verify files and directories

[root@ip-172-31-4-151 ec2-user]# tail -3 /etc/group

Verify package

Thank you for giving your valuable time to read the above information.

Follow us on 

Website :  www.ktexperts.com

Facebook Page : KTexperts

LinkedIn Page : KT EXPERTS

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Add Comment