Chef Flashcards

(65 cards)

1
Q

What is idempotent ?

A

That is: “multiple applications of the same action do not have side effects on the system state.” A simple example of an idempotent operation is mkdir -p:
mkdir -p /var/lib/statedir/myapp
No matter how many times we run this command, it will result in that tree being created. Another way of stating this about idempotent operations is, “running the tool over and over doesn’t change the system after the first time.”
Now to contrast that with convergence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between integration testing with Test kitchen and unit testing with chefspec ?

A

Chefspec tests are written in RSpec while Test Kitchen and unit testing with ChefSpec.
Integration tests are performed inside of a running system, such as virtual machine, while unit tests are executed in memory.
Unit tests focus on testing the Resource Collection while integration test check the state of a converged node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Test Kitchen can be used to write expectations about what will happen when a cookbook is deployed to what kind of system ?

A

A bare-metal machine
A cloud instance
A virtual instance
Any of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The Chef Development Kit (ChefDK) comes with a baseline set of tooling designed to aid in the development and testing of chef code/ How can the ChefDK’s tooling be expanded ?

A

Ruby Gems can be installed into the ChefDK with the chef gem command.
Knife plugins can extend the knife tooling to interact with other cloud providers.
Ohai plugins and hints can extend the information the ohai tool collects.
All of the above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is convergent ?

A

Generically, to converge means to bring [people or] things together. In configuration management, convergence means to bring the system state in line with a defined policy. That is, changes are made on the system only if they need to be made. A simple example of a convergent operation is:
if [ ! -d /var/lib/statedir/myapp ]; then
mkdir -p /var/lib/statedir/myapp
fi
This is convergent because we’re only executing the mkdir command if the desired directory does not exist. We also call this a “test and repair” operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Supermarket do?

A

Acts as an artifact repository for Chef cookbooks and tools.

Both public and private repositories for Chef cookbooks and tools utilize Supermarket.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of these tools is not part of the Chef Development Kit?

Ruby
Kitchen
The Chef Server
The Chef Client

A

The Chef Server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the role of Test Kitchen (or just Kitchen) in automated testing?

A

To provision platforms and run automated test suites in isolation. A separate testing framework such as InSpec, ServerSpec, or Bats is used to write the test expectations. Kitchen can work with many testing frameworks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Which of these commands would you run to see a list of nodes?
kitchen node list
chef node list
None of these choices
knife node list
A

knife node list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of these are valid ways to create a chef-repo to hold cookbooks? (Choose all that apply)

Using the chef generate repo command.
Using the chef-server-ctl generate repo command.
Using the knife generate repo command.
By generating a Chef repo “starter kit” from the Chef Server.

A

Using the chef generate repo command.

By generating a Chef repo “starter kit” from the Chef Server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the name of the utility that provides a web user interface for a Chef Server?

A

Chef Manage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which knife command can be used to register a physical server as a node with the Chef Server?
None of these choices.

The chef bootstrap command.
The knife node create command.

A

The knife bootstrap command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the name of the approach used by chef-client to know what configuration to apply?
test-and-repair
converge-and-verify
download-and-run

A

test-and-repair

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of these is a rule regarding a Chef Server organization’s name? (Note: the name field, not the full_name field) ?

It must contain one number and one letter.
It can only contain lowercase letters, digits, hyphens, and underscores.
It must be at least five characters long.
It must start with a lowercase letter.

A

It can only contain lowercase letters, digits, hyphens, and underscores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Default Resource Actions

A

:install - Default, installs the package.
:nothing - Does nothing until the resource is notified.
:purge - Debian specific, use :remove otherwise. Removes package and configuration.
:reconfig - Reconfigure the package. Requires a response file.
:remove - Removes the package.
:upgrade - Install and/or ensure that the package is the latest version.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How many Attribute types are there in chef ? what are they ?

A

Chef has 6 different attributes such as,

default - Attributes automatically set during the chef-client run.
force_default - Attribute type guaranteed to override default values. Set in cookbooks.
normal - Attribute type that persists with the node object at the end of a chef-client run.
override - Attribute type reset at the start of a chef-client run. Used in cookbooks, roles, and environments. Limit use in cookbooks unless it can't be avoided.
force_override - Attribute type used by cookbooks to have precedence over override attributes.
automatic - Attribute type determined by Ohai at the start of the chef-client run. Can't be overridden.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How can we define the attributes ?

A

Attributes are defined by:

    The state of the node itself
    Cookbooks (in attribute files and/or recipes)
    Roles
    Environments
    Policyfiles
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How to include a recipe into another recipe ?

A

include_recipe ‘cookbook::recipe’

Example:
include_recipe ‘base1::install’
include_recipe ‘base2::configure’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What indexes are available for chef search ?

A
Clients
Nodes
Environments
Roles
Databags(searchable individual)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What type of items can a run-list contains ?

A

Roles and Recipes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Where can attributes be set ?

A

Automatically(by ohai) and in recipes, nodes, roles and environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What chef package runs on nodes managed by chef to pull updated configuration ?

A

The chef-client

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does an environment consist of ?

A

A name, optional description, and optional list of cookbook versions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What chef package will you use on your workstation ?

A

Chef DK Kit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What chef CLI command will create a new cookbook ?
chef generate cookbook EX: chef generate cookbook /home/karthi/chef-repo/cookbooks/base
26
What does Test kitchen do ?
Test kitchen provides a test harness for running integration tests for configuration policies.
27
What is a cookbook ?
A cookbook is a collection of useful resources, recipes, and supporting files that can be complete a particular scenario.
28
What does kitchen do ?
Kitchen creates and provisions one or more nodes, configures them, runs the integration test suites, and deletes the node.
29
True or False. Chef configuration is written in Ruby
True. We have access to the full Ruby language when working with chef
30
How do you undo what a resource has already done ?
The undo configuration caused by a resource, you will need to use a different resource or different action on the same resource that has the opposite effect
31
What does 'chef generate repo' do?
It creates a chef repository to hold on chef configuration.
32
What tools can we use to ensure we're following chef's style guide and best practices ?
'foodcritic' and 'cookstyle' utilities allow us to lint our code.
33
Does chef use a push or pull based approach to deploy configuration changes ?
Pull based
34
What does it mean to write 'declarative' configuration ?
Declarative configuration specifies the desired end state, but not how to get there.
35
True or False. Integration tests are more low level than unit tests ?
False. Unit tests test the cookbooks at a lower level then integration tests.
36
What action is shared all resources ?
The ':nothing' action.
37
Does chef use a declarative or imperative approach to configuration ?
Declarative, although you can write imperative chef.
38
What plugin provides the chef server with a web UI ?
Chef Manage
39
What chef package stores the configuration of nodes ?
The Chef Server
40
How does Chefspec unit testing work ?
Chefspec creates a virtual node object that can be customized and calculates what would be run on the node.
41
True or False. We should use Wrapper cookbooks
True
42
True or False. Chef only does what it is told to do.
True, the only thing that causes chef to make a change is explicit resource action
43
What 'knife' command is used to push artifacts to the chef server ?
The 'knife upload' command.
44
True or False. Habitat is used by chef automate by default
False. You can choose to use habitat in a project's workflow, but it is not used by default.
45
How does chef Inspec communicates with remote machines ?
using SSH or WinRM
46
What does Chef DK includes ?
Everything needed to develop and test chef cookbook. It includes, - ruby - Berkshelf - chef - chef-client - kitchen - foodcritic - chefspec
47
In what ways can a chef-repo be generated ?
1. Using 'chef generate repo' OR | 2. Downloading a chef-repo starter kit from the chef manage UI
48
True or False. Inspec can test on remote nodes.
True
49
What methods provide access to data bags from within recipes ?
The 'data_bag', 'data_bag_item' and 'search' methods.
50
What chef product handles application automation?
Habitat
51
What does a 'knife bootstrap' do ?
'knife bootstrap' prepares a server to be a node of a chef server
52
True or False. A push-based configuration management approach requires the node to have an agent installed ?
False. The pull-based method needs the agent installed on the node.
53
True or False. Habitat can be deployed in a container based infrastructure ?
True
54
Data bags stores what type of data ?
Json data
55
What is command line tool use to manage a chef server ?
chef-server-ctl
56
True or False. Chef server organization names cannot include uppercase letters
True. Organization can only include lower case letters, numbers, hyphens and underscores.
57
What testing framework will you use for integration testing
Inspec
58
What are the three main ideas from the preferred chef development workflow ?
1. Source control management. 2. Test-Driven development 3. Wrapper cookbooks
59
What recipe do all generated cookbooks have ?
The default recipe
60
What happens when a chef-client run occurs ?
1. Get configuration data - Read information from client.rb file and Ohai attributes. 2. Authenticate w/ Chef server - Utilizes RSA key & node name to authenticate with Chef server. Will generate a new RSA key if this is the first connection. 3. Get/rebuild the node object - Pull node object from Chef server if this isn’t the first chef-client run. After the pull, the node object is rebuilt based on the node’s current state. 4. Expand the run-list - Compiles the list of roles and recipes to be applied. 5. Synchronize cookbooks - Request and download all of the files from cookbooks on the Chef server that are necessary to converge the run list and are different from the files already existing on the node. 6. Reset node attributes - Rebuild the attributes on the node object. 7. Compile the resource collection - Load the necessary Ruby code to converge the run-list. 8. Converge the node - Execute the run-list. 9. Update the node object, process exception & report handlers - Update the node object on the Chef server after the chef-client run finishes successfully. Also executing the exception and report handlers in the proper order. 10. Stop, wait for the next run - The chef-client waits until the next time it is executed.
61
What are some properties of the service resource
``` ignore_failure init_command notifies options pattern priority reload_command restart_command retries retry_delay service-name start_command status_command subscribes supports timeout ```
62
What are the timers of the 'subscribes' service ?
:before :delayed :immediate or :immediately
63
What are the 4 components of a resource?
a type, a name, one (or more) properties (with values), and one (or more) actions
64
What are guards used for
A guard property can be used to evaluate the state of a node during the execution phase of the chef-client run. Based on the results of this evaluation, a guard property is then used to tell the chef-client if it should continue executing a resource
65
What are the actions of the 'service' resource?
``` :disable :enable :nothing :reload :restart :start :stop ```