Chef Basics and Interview related qs

Venkata Chitturi
DevOps Process and Tools
2 min readMar 5, 2018

Discuss about chef and cm tools.

Chef is a configuration managment tools — Used to manage the autoamtion of deployments,configuation to treat/convert the infrastrcture as code.So you can repeat,store,debug your infrastrcture as similar to application code.

Chef basic imporatnt concepts are:

chef-clients, chef-server. chef-nodes,resources,receipes,cookbooks,data bags, roles, environment.

Resource → is the basic -a tiny -small — activity of your infrastrcture- like file,template,package,service etc.. ( example an individual in a team is — resource )

examples of resources are: chef_acl -resource — internet acces control list

recipes — is a collection of individual resources — to form a piece/part of infrastrcture.

cookbook → is a collection of receipes to form a functional part of inastrcture.

How do you manage dependencies in chef?

ans: using bershelf

install bershelfusin gem as → gem bershelf

it will create a berksfile → .berksfile and you will mention the what cookbooks your project is dependent on and mention source of cookbook in a list.

Can you explain your development model of chef cookbooks?

ans: I used chef-workstation to develop my cookbook- which will crete a default chef repo . For locla change to see my chef-server i used chef-solo.

editors used are: atom or sublimetext

TO spinup a new server/instance in my local i used “vagrant” — vagrant will use the oracle- virtualbox . and spinup a new instance/server by the commadn

vagrant up — create a new server

vagrant destroy — to delete the server

Can you explain how do you test your chef cookbooks/recepies?

I used test-kitchen tool integrated with vagrant,serverspec(like npm testing chek if something exists — if it exists returrns true / if not test wil fail) to test my cookbooks and recepies.

knife converge — will create a new server, intall chef-client, run cookbooks/recipes.

knife verify — will run the test in included in “/test/integration/default/” folder and check if my test cases are passing or not

knife test — will start from scratch and run the tests ad kill the intance once test are done.

we use converge and verify as part of day-to day develoment.

How do you specify the order of receipes in a cookbook?

we use “runlist” and inside the runlit we will give the order inwhich receipes should execute.

How does the configuration file will be stored in chef cookbooks?

Configuration files will be stored inside “/templates/filename.erb” ( in .erb) templates and in which variables/attributes will be mentioned.

How do you store your secrets in chef?

In chef we manage secrets using chef-vault or chef-databags .

we encrypt the chef-databag with secrets and store in the chef-server.

what is the attribute precedence in chef ?

attribute precedence is simply which attribute should be applied in recepies — either default or receipe level, role level or environment level

role,environment,receipe and default is the order from highest to lowest.

--

--

Venkata Chitturi
DevOps Process and Tools

DevOps Professional. Passionate on learning, implementing and sharing new things.