Chef DevOps



In the DevOps model, developers and system operators work closely together throughout the software development process to deploy software more frequently and more reliably. Many new third party and proprietary tools have been developed to support automation, measurement and sharing.

Chef: "IT automation for speed and awesomeness"

Chef is a configuration management tool for dealing with machine setup on physical servers, virtual machines and in the cloud. Many companies use Chef software to control and manage their infrastructure including Facebook, Etsy, Cheezburger, and Indiegogo.

But what does that really mean?

Configuration management is all about trying to ensure that the files and software you are expecting to be on a machine are present, configured correctly, and working as intended.

When you have only a single machine this is fairly simple. When you have five or ten servers, it is still possible to do this manually, but it may take all day. However, when your infrastructure scales up into the thousands we need a better way of doing things.

Infrastructure as code

Chef helps solve this problem by treating infrastructure as code. Rather than manually changing anything, the machine setup is described in a Chef recipe.

Collections of recipes are stored in a cookbook. One cookbook should relate to a single task, but can have a number of different server configurations involved (for example a web application with a database, will have two recipes, one for each part, stored together in a cookbook).

There is a Chef server which stores each of these cookbooks and as a new chef client node checks in with the server, recipes are sent to tell the node how to configure itself.

The client will then check in every now and again to make sure that no changes have occurred, and nothing needs to change. If it does, then the client deals with it. Patches and updates can be rolled out over your entire infrastructure by changing the recipe. No need to interact with each machine individually.

Chef configuration

Chef Configuration from https://www.chef.io/solutions/cloud-management/

Figure 1- Chef configuration

Recipes and cookbooks are the heart of the configuration management. They are written using the Ruby programming language, however, the domain specific language used by Chef is designed to be able to be understood by everyone. As the configuration is just code it can be tested and it can be version controlled. This means that there is less downtime, more reliable services and less stressed people on both the dev and ops sides.

Chef config files to install Apache

Chef Hello World screenshot

Figure 2: Chef config files to install Apache and add a hello world html page

So why is it awesome?

You want more? How about Chef Analytics - the ability to visualise everything going on in real time. It will check if something is going wrong and notify you before the problem becomes noticeable to your clients.

The Chef development kit allows you to write and manage your chef infrastructure from any machine and any operating system.

Chef's Knife allows you to manage the interface between your Chef bookshelf (the repository) and your chef server. The high availability and replication feature allows you to ensure that even if something goes wrong, the chef server is able to adapt and recreate your infrastructure as required, without outside help.




Define Chef and its architecture in DevOps?

The Chef is powerful automation tool to transform the Company infrastructure into a well-structured code. With the help of Chef, you may write scripts that are further used to automate the business processes. Of course, the processes are somewhat related to IT.



Chef Interview Questions


CHEF INFRASTRUCTURE

The three major components of any Chef architecture include – Chef server, Chef workstation, and Chef server. They need to arrange in the same format as shown below in the diagram.

  • Chef Server – This is a central storage house that stores necessary data necessary to configure the nodes.
  • Chef Node – A node is based on the chef-client architecture where nodes are referred as client responsible to share data across the network
  • Chef Workstation – This is a host that helps you to modify the configuration data and cookbooks then it is forwarded to the Chef Server.
Define Chef Resource and its functions in brief?

A Resource is used to represent a part of the infrastructure and its state, a package that you are interested in installing, a running service, or a file you are planning to create. Now, let us see the functions of resources in brief –

  • It helps you to describe the desired state of a configuration item.
  • You will know the process or steps that will be followed to bring a particular item in the desirable state.
  • You can specify the type of resources like template, package, or service etc.
  • It helps to list the resource properties and the additional details that are necessary.
  • Further, resources can be grouped into recipes to describe the working configurations.
Define Chef Recipe and its functions too?

When resources are grouped together, it becomes a Recipe that describes the working configurations and policy. With a Recipe, you will get to know everything necessary to configure a particular system. Let us have a quick look at functions of Recipe –

  • Software components can be installed or configured with Chef Recipe.
  • It is used to manage files and apps deployments too.
  • With one recipe, the other related recipes can also be executed.
Define a Chef Node and why is it important?

A node is a virtual machine or a physical server that is taken an important part of the Chef architecture. It is basically used to execute any resource in Chef.

What is a Cookbook and how is it different from the Recipe in Chef?

When resources are grouped together, it becomes a Recipe that describes the working configurations and policy. At the same time, when recipes are combined together, it becomes a cookbook and easy to manage as compared to a single recipe.

If the action for a Chef Resource is not defined then what will happen?

In case, an action for a Chef Resource is not defined then it will choose for the Default action. For example, both resources are the same as shown below in the screenshot. For the Resource 1, an action is not defined still it will take the default action. At the same time, when you define the action with ‘create’ command, it is also used to create the default action.

Resource 1Chef Interview Questions

Resource 2Chef Interview Questions

Do the code for both the Chef Recipes is same?

Chef Interview QuestionsNo, they are not the same. Remember that code is executed in the same way as it is written. For the Recipe 1, first the package is installed then the service will be created. At the same time, for Recipe 2, first the service is configured then the package is installed.


When system boosts, do you know some command that can be used to stop or disable the ‘httpd’ service?

Yes, I know. You can use the code given below to stop or disable the httpd service.Chef Interview Questions

What is DK in Chef?

DK is the workstation that allows users to interact with Chef. There are special tools available installed in the DK workstation space that can be used to make the interaction even better.

What is a Chef Repository and how it works?

A repository is a storehouse in Chef that can be used to accommodate cookbooks, environments, roles, or data bags etc. The Chef repository further is synchronized with GIT, a version control system to make its performance even better.

Why are SSL certificates used in Chef?

How can you sure that right data is accessed among Chef server and the Chef client? To make sure, you need to establish a secure SSL connection and continue your work.

Have you heard of the Signed header? Explain the concept in brief?

To validate the interaction between the node and the Chef server, signed header authentication is necessary.

How will you define the run-list in Chef?

With the help of run-list in chef, you can specify which Recipes needs to run and what should be the order of execution for Recipes.

  • Run-list makes sure that recipes are executed in the same order as defined by you. In case, there is some recipe that is added twice by mistake then it will not be made run two times by the run-list.
  • You also need to specify the node on which run-list should be executed. Rub-list is also defined as the object of the node that is stored on Chef server.
  • It is maintained on Knife then from the workstation it is transferred to Chef server and management Console in Chef.
Why are starter kits needed in the Chef?

To create the required configuration files in Chef, starter kids are necessary. It helps to define the clear information for each configuration file and easy interaction with the server. This is easy to download the starter kits and take it to the desired place on the workstation where you want to use them.

How to update a cookbook in Chef? Give answer based on your experience.

This is easy to update a cookbook in Chef and you can use any of the three methods given below based on your convenience –

  • Knife SSH can be run from the workstation.
  • Run the chef-client and then SSH in your server directly.
  • The chef-client can be used as a service or daemon and make it restarted after every selected time intervals say 15 or 20 mins.
How can you bootstrap in Chef and tell me the required information needed for the same purpose?

To bootstrap in Chef, you need the following information as given below –

  • The public IP address or the hostname of your node.
  • To log in to a particular node, you need the credentials details like username and password for the same.
  • Further, you may choose authentication based on keys instead of using any login credentials.
Explain your understanding of Test Kitchen in Chef?

With this answer, the interviewer can get a clear idea of your understanding of Test Kitchen in Chef.

It enables the cookbooks on the server and increases the development lifecycle too. Also, it helps you to create a variety of virtual machines in the cloud or locally.


What is chef in devops?

Chef is a configuration management tool for dealing with machine setup on physical servers, virtual machines and in the cloud.

What is a Node in Chef?

A Node represents a server and is typically a virtual machine, container instance, or physical server – basically any compute resource in your infrastructure that is managed by Chef.

What is chef in automation?

Chef is a powerful automation platform that transforms infrastructure into code.s The Chef server acts as a hub for configuration data.

What is a chef server?

The Chef server acts as a hub for configuration data. The Chef server stores cookbooks, the policies that are applied to nodes, and metadata that describes each registered node that is being managed by Chef. Nodes use the Chef client to ask the Chef server for configuration details, such as recipes, templates, and file distributions.

Why do we use SSL Certificates in chef?

An SSL certificate is used between the chef-client and the Chef server to ensure that each node has access to the right data.

What is SSL_CERT_FILE in chef?

Use the SSL_CERT_FILE environment variable to specify the location for the SSL certificate authority (CA) bundle that is used by the chef-client.

What is knife ssl check command in chef?

Run the knife ssl check subcommand to verify the state of the SSL certificate, and then use the reponse to help troubleshoot issues that may be present.

What is chef resources file?

A file resource is used to manage files directly on a node.

A file resource block manages files that exist on nodes. For example, to write the home page for an Apache website:

file ‘/var/www/customers/public_html/index.php’ do

content ‘<html>This is a placeholder for the home page.</html>’

mode ‘0755’

owner ‘web_admin’

group ‘web_admin’

end


What are Data Bags?

A data bag is a global variable that is stored as JSON data and is accessible from a Chef server. A data bag is indexed for searching and can be loaded by a recipe or accessed during a search.

What is chef_acl resource in chef?

Use the chef_acl resource to interact with access control lists (ACLs) that exist on the Chef server.

Syntax: The syntax for using the chef_acl resource in a recipe is as follows:

chef_acl ‘name’ do

attribute ‘value’ # see properties section below

action :action # see actions section below

end

What information do you need in order to bootstrap in Chef?

Just mention the information you need in order to bootstrap:

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.

What is the command you use to upload a cookbook to the Chef server?

You can directly mention the command to upload a cookbook to the Chef server “knife cookbook upload”.

What is run-list in Chef?

run-list lets you specify which Recipes to run, and the order in which to run them. The run-list is important when you have multiple Cookbooks, and the order in which they run matters.

Depending on the discussion if you think more explanation is required just mention the below points

A run-list is:

An ordered list of roles and/or recipes that are run in the exact order defined in the run-list; if a recipe appears more than once in the run-list, the chef-client will not run it twice.

Always specific to the node on which it runs; nodes may have a run-list that is identical to the run-list used by other nodes.

Stored as part of the node object on the Chef server.

Maintained using knife, and then uploaded from the workstation to the Chef server, or is maintained using the Chef management console.

How do you apply an updated Cookbook to your node in Chef?

There are three ways to apply an updated Cookbook to a node you can mention all or any one, I will suggest you to mention all three:

-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.

Write a service Resource that stops and then disables the httpd service from starting when the system boots in Chef?

Use the below Resource to stop and disable the httpd service from starting when system boots.

service 'httpd' do

action [:stop, :disable]

end

Are these two Chef recipes the same?

package 'httpd'

service 'httpd' do

action [:enable, :start]

end


Chef Interview Questions And Answers

1) What is chef in devops?

A) Chef is a configuration management tool for dealing with machine setup on physical servers, virtual machines and in the cloud.
Many companies use Chef software to control and manage their infrastructure including Facebook, Etsy, Cheezburger, and Indiegogo.

2) What is chef in automation?

A) Chef is a powerful automation platform that transforms infrastructure into code.s The Chef server acts as a hub for configuration data.
The Chef server stores cookbooks, the policies that are applied to nodes, and metadata that describes each registered node that is being managed by the chef-client.

3) What is chef DK?

A) The Chef DK workstation is the location where users interact with Chef. On the workstation users author and test cookbooks using tools such as Test Kitchen and interact with the Chef server using the knife and chef command line tools.

4) What are chef client nodes?

A) Chef client nodes are the machines that are managed by Chef. The Chef client is installed on each node and is used to configure the node to its desired state.

5) What is a chef server?

A) The Chef server acts as a hub for configuration data. The Chef server stores cookbooks, the policies that are applied to nodes, and metadata that describes each registered node that is being managed by Chef. Nodes use the Chef client to ask the Chef server for configuration details, such as recipes, templates, and file distributions.

6) What are work stations in chef?

A) A workstation is a computer running the Chef Development Kit (ChefDK) that is used to author cookbooks, interact with the Chef server, and interact with nodes.

The workstation is the location from which most users do most of their work, including:

Developing and testing cookbooks and recipes
Testing Chef code
Keeping the chef-repo synchronized with version source control
Configuring organizational policy, including defining roles and environments, and ensuring that critical data is stored in data bags
Interacting with nodes, as (or when) required, such as performing a bootstrap operation

7) What are Cookbooks in chef?

A) A cookbook is the fundamental unit of configuration and policy distribution. A cookbook defines a scenario and contains everything that is required to support that scenario:

Recipes that specify the resources to use and the order in which they are to be applied
Attribute values
File distributions
Templates
Extensions to Chef, such as custom resources and libraries

8) What is chef repo?

A) The chef-repo is a directory on your workstation that stores:

Cookbooks (including recipes, attributes, custom resources, libraries, and templates)
Roles
Data bags
Environments
The chef-repo directory should be synchronized with a version control system, such as git. All of the data in the chef-repo should be treated like source code.

9) What is chef-client Run?

A) A “chef-client run” is the term used to describe a series of steps that are taken by the chef-client when it is configuring a node.

10) What is chef validator?

A) chef-validator – Every request made by the chef-client to the Chef server must be an authenticated request using the Chef server API and a private key. When the chef-client makes a request to the Chef server, the chef-client authenticates each request using a private key located in /etc/chef/client.pem.

Chef Interview Questions Devops

11) Why do we use SSL Certificates in chef?

A) An SSL certificate is used between the chef-client and the Chef server to ensure that each node has access to the right data.

12) What are Signed Headers in chef?

A) Signed header authentication is used to validate communications between the Chef server and any node that is being managed by the Chef server.

13) What is SSL_CERT_FILE in chef?

A) Use the SSL_CERT_FILE environment variable to specify the location for the SSL certificate authority (CA) bundle that is used by the chef-client.

14) What are Knife Subcommands in chef?

A) The chef-client includes two knife commands for managing SSL certificates:

Use knife ssl check to troubleshoot SSL certificate issues
Use knife ssl fetch to pull down a certificate from the Chef server to the /.chef/trusted_certs directory on the workstation.

15) What is knife ssl check command in chef?

A) Run the knife ssl check subcommand to verify the state of the SSL certificate, and then use the reponse to help troubleshoot issues that may be present.

16) What is knife ssl fetch command in chef?

A) Run the knife ssl fetch to download the self-signed certificate from the Chef server to the /.chef/trusted_certs directory on a workstation.

17) What are Data Bags?

A) A data bag is a global variable that is stored as JSON data and is accessible from a Chef server. A data bag is indexed for searching and can be loaded by a recipe or accessed during a search.

18) What are recipes in chef?

A) A recipe is the most fundamental configuration element within the organization. A recipe:

Is authored using Ruby, which is a programming language designed to read and behave in a predictable manner
Is mostly a collection of resources, defined using patterns (resource names, attribute-value pairs, and actions); helper code is added around this using Ruby, when needed
Must define everything that is required to configure part of a system
Must be stored in a cookbook
May be included in a recipe
May use the results of a search query and read the contents of a data bag (including an encrypted data bag)
May have a dependency on one (or more) recipes
May tag a node to facilitate the creation of arbitrary groupings
Must be added to a run-list before it can be used by the chef-client
Is always executed in the same order as listed in a run-list

19) What is chef resources file?

A) A file resource is used to manage files directly on a node.

A file resource block manages files that exist on nodes. For example, to write the home page for an Apache website:

file ‘/var/www/customers/public_html/index.php’ do
content ‘<html>This is a placeholder for the home page.</html>’
mode ‘0755’
owner ‘web_admin’
group ‘web_admin’
end

20) What is apt_package resource in chef?

Answer) Use the apt_package resource to manage packages on Debian and Ubuntu platforms.

apt_package Syntax:

A apt_package resource block manages a package on a node, typically by installing it. The simplest use of the apt_package resource is:

apt_package ‘package_name’

Chef Interview Questions Magazine

21) What is apt_preference resource in chef?

A) The apt_preference resource allows for the creation of APT preference files. Preference files are used to control which package versions and sources are prioritized during installation. New in Chef Client 13.3

Syntax:

apt_preference ‘package_name’ do
action :add
end

22) What is apt_repository resource?

A) Use the apt_repository resource to specify additional APT repositories. Adding a new repository will update APT package cache immediately.

apt_repository ‘nginx’ do
uri ‘http://nginx.org/packages/ubuntu/’
components [‘nginx’]
end

23) What is apt_update resource in chef?

A) Use the apt_update resource to manage APT repository updates on Debian and Ubuntu platforms.

24) what is bff_package resource in chef?

A) Use the bff_package resource to manage packages for the AIX platform using the installp utility. When a package is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources.

25) What is cab_package resource in chef?

A) Use the cab_package resource to install or remove Microsoft Windows cabinet (.cab) packages.

26) What is chef_gem?

A) Use the chef_gem resource to install a gem only for the instance of Ruby that is dedicated to the chef-client. When a gem is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources.

27) What is chef_acl resource in chef?

A) Use the chef_acl resource to interact with access control lists (ACLs) that exist on the Chef server.

Syntax: The syntax for using the chef_acl resource in a recipe is as follows:

chef_acl ‘name’ do
attribute ‘value’ # see properties section below

action :action # see actions section below
end

28) What is chef_client resource?

A) A chef-client is an agent that runs locally on every node that is under management by Chef. When a chef-client is run, it will perform all of the steps that are required to bring the node into the expected state, including:

Registering and authenticating the node with the Chef server
Building the node object
Synchronizing cookbooks
Compiling the resource collection by loading each of the required cookbooks, including recipes, attributes, and all other dependencies
Taking the appropriate and required actions to configure the node
Looking for exceptions and notifications, handling each as required

29) What is chef_container resource?

A) chef_container resource is used to interact with container objects that exist on the Chef server.

30) What is chef_data_bag_item?

A) A data bag is a container of related data bag items, where each individual data bag item is a JSON file. knife can load a data bag item by specifying the name of the data bag to which the item belongs and then the filename of the data bag item.

Use the chef_data_bag_item resource to manage data bag items.

Syntax – The syntax for using the chef_data_bag_item resource in a recipe is as follows:

chef_data_bag_item ‘name’ do
attribute ‘value’

action :action
end

Chef Tool Interview Questions

31) What is chef_data_bag resource?

A) A data bag is a global variable that is stored as JSON data and is accessible from a Chef server. A data bag is indexed for searching and can be loaded by a recipe or accessed during a search.

Use the chef_data_bag resource to manage data bags.

32) What is chef_environment resource?

A) chef_environment resource to manage environments. An environment is a way to map an organization’s real-life workflow to what can be configured and managed when using Chef server. Every organization begins with a single environment called the _default environment, which cannot be modified (or deleted). Additional environments can be created to reflect each organization’s patterns and workflow.

33) What is chef_group resource?

A) chef_group resource is used to interact with group objects that exist on the Chef server.

34) What is chef_handler resource?

A) The chef_handler resource is used to enable handlers during a chef-client run. The resource allows arguments to be passed to the chef-client, which then applies the conditions defined by the custom handler to the node attribute data collected during the chef-client run, and then processes the handler based on that data.

35) What is the chef_mirror resource?

A) The chef_mirror resource to mirror objects in the chef-repo to a specified location.

36) What is chef_node resource?

A) A node is any machine—physical, virtual, cloud, network device, etc.—that is under management by Chef. chef_node resource is used to manage nodes.

37) What is chef_organization resource?

A) The chef_organization resource to interact with organization objects that exist on the Chef server.

38) What is chef_role resource?

A) The chef_role resource to manage roles. A role is a way to define certain patterns and processes that exist across nodes in an organization as belonging to a single job function. Each role consists of zero (or more) attributes and a run-list. Each node can have zero (or more) roles assigned to it.

39) What is chef_user resource?

A) The chef_user resource is used to manage users.

40) What is chocolatey_package resource?

A) A chocolatey_package resource manages packages using Chocolatey on the Microsoft Windows platform. The simplest use of the chocolatey_package resource is:

chocolatey_package ‘package_name’

Chef Tool Interview Questions And Answers

41) What is cookbook_file resource?

A) The cookbook_file resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the chef-client.

Syntax – A cookbook_file resource block manages files by using files that exist within a cookbook’s /files directory. For example, to write the home page for an Apache website:

cookbook_file ‘/var/www/customers/public_html/index.php’ do
source ‘index.php’
owner ‘web_admin’
group ‘web_admin’
mode ‘0755’
action :create
end

42) What is cron resource?

A) The cron resource is used to manage cron entries for time-based job scheduling.

43) What is dnf_package resource?

A) the dnf_package resource to install, upgrade, and remove packages with DNF for Fedora platforms. The dnf_package resource is able to resolve provides data for packages much like DNF can do when it is run from the command line. This allows a variety of options for installing packages, like minimum versions, virtual provides, and library names.

44) What is dpkg_package resource?

A) The dpkg_package resource to manage packages for the dpkg platform. When a package is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources.

45) What is metadata.rb in chef?

A) Every cookbook requires a small amount of metadata. A file named metadata.rb is located at the top of every cookbook directory structure. The contents of the metadata.rb file provides hints to the Chef server to help ensure that cookbooks are deployed to each node correctly.

46) What information stored in metadata.rb file?

A) A metadata.rb file is:

Located at the top level of a cookbook’s directory structure.
Compiled whenever a cookbook is uploaded to the Chef server or when the knife cookbook metadata subcommand is run, and then stored as JSON data.
Created automatically by knife whenever the knife cookbook create subcommand is run.
Edited using a text editor, and then re-uploaded to the Chef server as part of a cookbook upload.

47) What is Berkshelf in chef?

A) Berkshelf is a dependency manager for Chef cookbooks. With it, you can easily depend on community cookbooks and have them safely included in your workflow.

48) What is Berksfile in chef?

A) A Berksfile describes the set of sources and dependencies needed to use a cookbook. It is used in conjunction with the berks command.

49) What is Cookbook Keyword in chef?

A) The cookbook keyword allows the user to define where a cookbook is installed from, or to set additional version constraints. It can also be used to install additional cookbooks, for example to use during testing.

50) What is kitchen (executable) in chef?

A) kitchen is the command-line tool for Kitchen, an integration testing tool used by the chef-client. Kitchen runs tests against any combination of platforms using any combination of test suites.

Chef Interview Questions And Answers PDF

51) What is kitchen converge in chef?

A) Use the converge subcommand to converge one (or more) instances. Instances are based on the list of platforms in the .kitchen.yml file. This process will install the chef-client on an instance using the omnibus installer, upload cookbook files and minimal configuration to the instance, and then start a chef-client run using the run-list and attributes specified in the .kitchen.yml file.

Syntax – $ kitchen converge PLATFORMS (options)

52) What is kitchen create in chef?

A) Use the create subcommand to create one (or more) instances. Instances are based on the list of platforms and suites in the .kitchen.yml file.

Syntax – This subcommand has the following syntax:

$ kitchen create PLATFORMS (options)

53) What is kitchen destroy in chef?

A) Use the destroy subcommand to delete one (or more) instances. Instances are based on the list of platforms and suites in the .kitchen.yml file.

Syntax – This subcommand has the following syntax:

$ kitchen destroy PLATFORMS (options)

54) What is kitchen diagnose in chef?

A) Use the diagnose subcommand to show a computed diagnostic configuration for one (or more) instances. This subcommand will make all implicit configuration settings explicit because it echoes back all of the configuration data as YAML.

Syntax – This subcommand has the following syntax:

$ kitchen diagnose PLATFORMS (options)

55) What is kitchen driver create in chef?

A) Use the driver create subcommand to create a new Kitchen driver in the RubyGems project.

Syntax – This subcommand has the following syntax:

$ kitchen driver create NAME

56) What is kitchen driver discover?

A) Use the driver discover subcommand to discover Kitchen driver that have been published to RubyGems. This subcommand will return all RubyGems that are match kitchen-*.

Syntax – This subcommand has the following syntax:

$ kitchen driver discover

57) What kitchen exec in chef?

A) Use the exec subcommand to execute a command on a remote instance.

Syntax – This subcommand has the following syntax:

$ kitchen exec PLATFORMS (options)

58) What is kitchen init command in chef?

A) Use the init subcommand to create an initial Kitchen environment, including:

Creating a .kitchen.yml file
Appending Kitchen to the RubyGems file, .gitignore, and .thor
Creating the test/integration/default directory

Syntax – This subcommand has the following syntax:

$ kitchen init

59) What is kitchen list in chef?

A) Use the list subcommand to view the list of instances. Instances are based on the list of platforms in the .kitchen.yml file. Kitchen will auto-name instances by combining a suite name with a platform name. For example, if a suite is named default and a platform is named ubuntu-10.04, then the instance would be default-ubuntu-10.04. This ensures that Kitchen instances have safe DNS and hostname records.

Syntax – This subcommand has the following syntax:

$ kitchen list PLATFORMS (options)

60) What is kitchen login command in chef?

A) Use the login subcommand to log in to a single instance. Instances are based on the list of platforms and suites in the .kitchen.yml file. After logging in successfully, the instance can be interacted with just like any other virtual machine, including adding or removing packages, starting or stopping services, and so on. It’s a sandbox. Make any change necessary to help improve the coverage for cookbook testing.

Syntax – This subcommand has the following syntax:

$ kitchen login PLATFORM (options)

Chef Interview Questions And Answers For Experienced

61) What is kitchen setup c0mmand in chef?

A) Use the setup subcommand to set up one (or more) instances. Instances are based on the list of platforms in the .kitchen.yml file.

Syntax – This subcommand has the following syntax:

$ kitchen setup PLATFORMS (options)

62) What is kitchen test command in chef?

A) Use the test subcommand to test one (or more) verified instances. Instances are based on the list of platforms and suites in the .kitchen.yml file. This subcommand will create a new instance (cleaning up a previous instance, if necessary), converge that instance, set up the test harness, verify the instance using that test harness, and then destroy the instance.

In general, use the test subcommand to verify the end-to-end quality of a cookbook. Use the converge and verify subcommands during the normal the day-to-day development of a cookbook.

Syntax – This subcommand has the following syntax:

$ kitchen test PLATFORMS (options)

63) What is kitchen verify command in chef?

A) Use the verify subcommand to verify one (or more) instances. Instances are based on the list of platforms and suites in the .kitchen.yml file.

In general, use the test subcommand to verify the end-to-end quality of a cookbook. Use the converge and verify subcommands during the normal the day-to-day development of a cookbook.

Syntax – This subcommand has the following syntax:

$ kitchen verify PLATFORMS (options)

64) What is kitchen version command in chef?

A) Use the version subcommand to print the version of Kitchen.

Syntax – This subcommand has the following syntax:

$ kitchen version

65) What are handlers in chef?

A) Handlers are used to identify situations that arise during a chef-client run, and then tell the chef-client how to handle these situations when they occur.

66) How many types of handlers are there in chef? What are they?

A) In chef there are three types of handlers are there they are:
Exception Handler
Report Handler
Start Handler

67) What is exception handler in chef?

A) An exception handler is used to identify situations that have caused a chef-client run to fail. An exception handler can be loaded at the start of a chef-client run by adding a recipe that contains the chef_handler resource to a node’s run-list. An exception handler runs when the failed? property for the run_status object returns true.

68) What is a report handler in chef?

A) A report handler is used when a chef-client run succeeds and reports back on certain details about that chef-client run. A report handler can be loaded at the start of a chef-client run by adding a recipe that contains the chef_handler resource to a node’s run-list. A report handler runs when the success? property for the run_status object returns true.

69) What is start handler in chef?

A) A start handler is used to run events at the beginning of the chef-client run. A start handler can be loaded at the start of a chef-client run by adding the start handler to the start_handlers setting in the client.rb file or by installing the gem that contains the start handler by using the chef_gem resource in a recipe in the chef-client cookbook.

70) What is Handler DSL in chef?

A) Use the Handler DSL to attach a callback to an event. If the event occurs during the chef-client run, the associated callback is executed. For example:

Sending email if a chef-client run fails
Sending a notification to chat application if an audit run fails
Aggregating statistics about resources updated during a chef-client runs to StatsD

Chef Devops Interview Questions

71) What is Knife and what is the purpose of using Knife in chef?

A) Knife is a command-line tool that provides an interface between a local chef-repo and the Chef server. knife helps users to manage:

Nodes
Cookbooks and recipes
Roles, Environments, and Data Bags
Resources within various cloud environments
The installation of the chef-client onto nodes
Searching of indexed data on the Chef server

72) What are the different Knife plugins for cloud hosting platforms?

A) There are different knife plugins available for cloud hosting platforms:
knife azure, knife bluebox, knife ec2, knife eucalyptus, knife google, knife linode, knife openstack, and knife rackspace

73) What is Ohai in chef?

A) Ohai is a tool that is used to collect system configuration data, which is provided to the chef-client for use within cookbooks. Ohai is run by the chef-client at the beginning of every Chef run to determine system state. Ohai includes many built-in plugins to detect common configuration details as well as a plugin model for writing custom plugins.

74) Why do we use chef-jenkins plugin in chef?

A) chef-jenkins adds the ability to use Jenkins to drive continuous deployment and synchronization of environments from a git repository.

75) Why do we use jclouds-chef plugin in chef?

A) jclouds-chef plugin adds Java and Clojure components to the Chef server API REST API.

76) Why do we use chef-hatch-repo in chef?

A) chef-hatch-repo plugin adds a knife plugin and a Vagrant provisioner that can launch a self-managed Chef server in a virtual machine or Amazon EC2.

Real-Time Chef Interview Questions

77) Why do we use chef-trac-hacks in chef?

A) chef-trac-hacks adds the ability to fill a coordination gap between Amazon Web Services (AWS) and the chef-client.

78) What is chef-deploy plugin in chef and what is the purpose of using it?

A) chef-deploy adds a gem that contains resources and providers for deploying Ruby web applications from recipes.

79) What is kitchenplan in chef?

A) Kitchenplan is a utility for automating the installation and configuration of a workstation on macOS.

80) What is stove in chef?

A) Stove is a utility for releasing and managing cookbooks.

81) What are the benefits of Devops?

A) There are many benefits of using devops, explain about your devops experience.

Technical benefits:

Continuous software delivery
Less complex problems to fix
Faster resolution of problems
Business benefits:

Faster delivery of features
More stable operating environments
More time available to add value (rather than fix/maintain)

82) What is Vagrant in chef?

A) Vagrant helps Test Kitchen communicate with VirtualBox and configures things like available memory and network settings.

1 Comments

Previous Post Next Post