Chef Flashcards Preview

DEVOPS > Chef > Flashcards

Flashcards in Chef Deck (78):
1

What is Chef?

A configuration management platform that provides a way to transforms infrastructure into code and write scripts that are used to automate processes.

2

What are the main 3 architectural components of Chef

Chef Server, Chef Node, Chef Workstation

3

What is a Chef Server

The Chef Server is the central store of your infrastructure’s configuration data. The Chef Server stores the recipe and cookbook data necessary to configure your nodes and provides search, a powerful tool that allows you to dynamically drive node configuration based on data.

4

What is a Chef Node

A Node is any host that is configured using Chef-client. Chef-client runs on your nodes, contacting the Chef Server for the information necessary to configure the node. Since a Node is a machine that runs the Chef-client software, nodes are sometimes referred to as “clients”.

5

what is a Chef Workstation

A Chef Workstation is the host you use to modify your cookbooks and other configuration data. All the configurations are first tested in the Chef Workstation and then it is forwarded to the Chef Server.

6

What is Knife

CLI tool that runs on workstation - Knife is used to upload configuration changes to the chef server via ssh

7

What is a Resource in Chef?

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. A block of Resource can be considered as a Recipe.

8

What is a Recipe in Chef?

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.

Now after the definition I will explain the functions of Recipes by including the following points:

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

9

What is a Node in Chef?

any compute resource in your infrastructure that is managed by Chef.

10

How does a Cookbook differ from a Recipe in Chef?

A Recipe is a collection of Resources, and primarily 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.

11

What happens when you don’t specify a Resource’s action in Chef?

When you don’t specify a resource’s action, Chef applies the default action.

12

Are these two Chef recipes the same?
package 'httpd'
service 'httpd' do
action [:enable, :start]
end
&&
service 'httpd' do
action [:enable, :start]
end
package 'httpd'

No, they are not. Remember that Chef applies resources in the order they appear. So the first Recipe ensures that the httpd package is installed and then configures the service. The second Recipe configures the service and then ensures the package is installed.

13

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

service 'httpd' do
action [:stop, :disable]
end

14

How does Chef-apply differ from Chef-client?

Chef-apply is an executable program that runs a single Recipe from the command line. It is a part of the Chef development kit and a great way to explore resources.

Chef-client applies a Cookbook. It is used for production purposes where you typically run Chef-client to apply one or more cookbooks.

15

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.

16

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

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

17

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.

18

What is the role of Starter Kit in Chef?

Starter Kit will create the necessary configuration files like chef directory, knife.rb, the ORGANIZATION-validator.pem, and USER.pem files etc. with the correct information that is required to interact with the Chef server.

Now tell how to use Starter Kit, you can simply download the starter kit and then move it to the desired location on your workstation.

19

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

“knife cookbook upload”

20

What would you set your cookbook’s version to once it is ready to use in production?

According to Semantic Versioning, you should set your cookbook’s version number to 1.0.0 once it is ready to use in production.

21

What is the value of local development using Test Kitchen in Chef?

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.
It enables you to run your cookbooks on servers that resemble those that you use in production.
It speeds up the development cycle by automatically provisioning and tearing down temporary instances, resolving cookbook dependencies, and applying your cookbooks to your instances.

22

Where can you get reusable cookbooks that are written and maintained by the Chef community?

Chef Supermarket, https://supermarket.chef.io.

23

after installing package httpd, how do we check whether it is configured/installed into machines?

sudo service httpd status, If you are using centos: systemctl status httpd.service

24

what is version control

management of changes to documents, code, computer programs, web sites,
1.0.0 = first int is major release, second int is minor release, third int is patch

25

Is Chef push or Pull

both

26

chef client pull interval (default)

30-35 min

27

How does chef server install

it uses recipes and cookbooks to deploy chef server

28

receipes are stored in what kind of file

.rb . ruby

29

resources in recipes start with a ____ and end with an ____ unless you ______

do,end,take all the defaults

30

how do you apply a receipe

chef-apply

31

if you do not specify properties (attributes) in a resource, what do they default to

the class defaults

32

what is contained in a resource

properties defined by the class
actions defined by the class

33

multiple actions in a resource get placed in a _____

list [list]

34

What is pre-convergence

Phase before chef is configured on a node and code linting - ruby-c and foodcritic

35

What is convergence

Occurs when chef is run on a node and resources are put in the desired state - when you run chef-client

36

What is post-convergence

After the chef convergence - node is in a verified desired state

37

What is foodcritic

Foodcritic is a static linting tool that analyzes all of the Ruby code that is authored in a cookbook against a number of rules, and then returns a list of violations.

38

What is linting

Linting is the process of running a program that will analyse code for potential errors.

39

What is a provider

providers are what do the work to enforce the desired configuarion - ie yum

40

what is a resource

A resource is a statement of desired configuration (inside a recipe) for an item. It describes the desired state and steps for achieving the desired configuration

41

a resource maps to a _____________

provider (which defines the steps to achieve that desired state of configuration)

42

a chef run is also known as

convergence

43

what is idempotence

can be applied multiple times without changing the result beyond the initial application.

44

how many components does a resource have

4

45

what are the 4 components of a resource

1. resource type
2. resource name
3. resource properties
4. actions to be applied to the resource

46

what language does chef use

ruby

47

blocks of ruby code start with a ____ and end with an ____

do, end

48

the default action item for package resource is:

install

49

which resource type is not idempotent

execute

50

the default action item for service resource is:

nothing

51

the default action item for file resource is;

create

52

command to execute chef code locally

chef-client --local-mode filename.rb

53

&&

if first commands exits with no errors, run the second command

54

how can you add idempotence to an execute resource

add not-if or only_if guards

55

how do you comment out ruby code

#

56

what is a chef custom resource

extension of Chef that adds your own resources and assign properties

57

not_if prevent a resource from executing when the condition returns as _______

true

58

if a recipe is included multiple times in a run-list - how many times will it be executed

once

59

typically resources are executed in the order they are written, what can change this behavior

a notifies or subscribes directive

60

what is a notifies directive

allows a resource to notify another resource to take action

61

what is a subscribes directive

allows a resource to listen to another resource and take action if the state of the resource being listen to changes

62

what is a run-list

a run list is a list of cookbooks or recipes that are to be executed on a given node

63

syntax for including a recipe from an external cookbook

include_recipe 'cookbookname::recipename'

64

what must be done prior to including a recipe from an external cookbook

create a depandancy in the metadata.rb file in the existing cookbook

65

what is a chef cookbook

fundamental unit of configuration and policy distribution in chef

66

what is contained in a cookbook (5)

1. recipes
2. Attribute files
3. file distribution
4. Templates
5. Extentions (libraries, custom resources)

67

some of the things metadata.rb file contains (3)

1. chef version required to run
2. dependencies
3. versioning
4. cookbook name
5. cookbook maintainer

68

what is the default recipe filename when creating a cookbook

default.rb

69

if you were to include a cookbook without a recipe in a runlist what would it run.

cookbookname::default

70

what is happening in here: run_list "recipe{apache::default]"

apache cookbook would run using only the default recipe, no other recipes would be used unless called in default

71

command to generate a cookbook

#chef generate cookbook

72

what is a unit test

tests your cookbook resources with an in memory implementation of chef server

73

purpose of chef environments

separate production testing staging and associate one or more cookbook versions

74

what is berkshelf

allows you to specify public or private supermarkets and declare cookbooks that you depend on

75

command to fetch supermarket dependencies

berks install

76

command to upload supermarket cookbooks and depandancies to chef server

berks upload

77

what is a wrapper cookbook

allows you to modify the behavior of an upstream cookbook without forking or vendoring them

78

what is ohai

Ohai is a tool that is used to collect system configuration data, which is provided to the chef-client for use within cookbooks.