Chef (Software) Interview Questions

 Q.What Is A Resource? Ans: A resource represents a piece of infrastructure and its desired state, such as a package that should be installed, a service that should be running, or a file that should be generated. Q.What Is A Recipe? Ans: A recipe is a collection of resources that describes a particular configuration or policy. A recipe describes everything that is required to configure part of a system. Recipes do things such as:

  • Install and configure software components.
  • Manage files.
  • Deploy applications.
  • Execute other recipes.

Q.What Happens When You Don’t Specify A Resource’s Action? Ans: When you don’t specify a resource’s action, Chef applies the default action. Q.Write A Service Resource That Stops And Then Disables The Httpd Service From Starting When The System Boots? Ans:

  • Service ‘httpd’ do
  • Action
  • End

Q.How Does A Cookbook Differ From A Recipe? Ans: A recipe is a collection of resources, and typically configures a software package or some piece of infrastructure. A cookbook groups together recipes and other information in a way that is more manageable than having just recipes alone. For example, in this lesson you used a template resource to manage your HTML home page from an external file. The recipe stated the configuration policy for your web site, and the template file contained the data. You used a cookbook to package both parts up into a single unit that you can later deploy. Q.How Does Chef-apply Differ From Chef-client? Ans: Chef-apply apply a single recipe; chef-client applies a cookbook. For learning purposes, we had you start off with chef-apply because it helps you understand the basics quickly. In practice, chef-apply is useful when you want to quickly test something out. But for production purposes, you typically run chef-client to apply one or more cookbooks. Q.What’s The Run-list? Ans: The run-list lets you specify which recipes to run, and the order in which to run them. The run-list is important for when you have multiple cookbooks, and the order in which they run matters. Q.What Are The Two Ways To Set Up A Chef Server? Ans:

  • Install an instance on your own infrastructure.
  • Use hosted Chef.

Q.What’s The Role Of The Starter Kit? Ans: The Starter Kit provides certificates and other files that enable you to securely communicate with the Chef server. Q.What Is A Node? Ans: A node represents a server and is typically a virtual machine, container instance, or physical server – basically any compute resource in your infrastructure that’s managed by Chef. Q.What Information Do You Need To In Order To Bootstrap? Ans: You need:

  • Your node’s host name or public IP address.
  • A user name and password you can log on to your node with.
  • Alternatively, you can use key-based authentication instead of providing a user name and password.

Q.What Happens During The Bootstrap Process? Ans: During the bootstrap process, the node downloads and installs chef-client, registers itself with the Chef server, and does an initial check in. During this check in, the node applies any cookbooks that are part of its run-list. Q.Which Of The Following Lets You Verify That Your Node Has Successfully Bootstrapped? Ans:

  • The Chef management console.
  • Knife node list
  • Knife node show
  • You can use all three of these methods.

Q.What Is The Command You Use To Upload A Cookbook To The Chef Server? Ans: Knife cookbook upload. Q.How Do You Apply An Updated Cookbook To Your Node? Ans: We mentioned two ways. Run knife Ssh from your workstation. SSH directly into your server and run chef-client. You can also run chef-client as a daemon, or service, to check in with the Chef server on a regular interval, say every 15 or 30 minutes. Update your Apache cookbook to display your node’s host name, platform, total installed memory, and number of CPUs in addition to its FQDN on the home page. Update index.html.erb like this. hello from <%= node %>< /h1>

<%= node  %>

<%= node  %> – <%= node %>

<%= node  %> RAM

<%= node  %> CPUs

Then upload your cookbook and run it on your node. Q. What Would You Set Your Cookbook’s Version To Once It’s Ready To Use In Production? Ans: According to Semantic Versioning, you should set your cookbook’s version number to 1.0.0 at the point it’s ready to use in production. Q. Create A Second Node And Apply The Awesome Customers Cookbook To It. How Long Does It Take? Ans: You already accomplished the majority of the tasks that you need. You wrote the awesome customers cookbook, uploaded it and its dependent cookbooks to the Chef server, applied the awesome customers cookbook to your node, and verified that everything’s working. All you need to do now is:

  • Bring up a second Red Hat Enterprise Linux or Centos node.
  • Copy your secret key file to your second node.
  • Bootstrap your node the same way as before. Because you include the awesome customers cookbook in your run-list, your node will apply that cookbook during the bootstrap process.
  • The result is a second node that’s configured identically to the first one. The process should take far less time because you already did most of the work.
  • Now when you fix an issue or add a new feature, you’ll be able to deploy and verify your update much more quickly!

Q. What’s The Value Of Local Development Using Test Kitchen? Ans: Local development with Test Kitchen:

  • Enables you to use a variety of virtualization providers that create virtual machine or container instances locally on your workstation or in the cloud.
  • Enables you to run your cookbooks on servers that resemble those that you use in production.
  • Speeds up the development cycle by automatically provisioning and tearing down temporary instances, resolving cookbook dependencies, and applying your cookbooks to your instances.