Chef Flashcards
What is idempotent ?
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.
What is the difference between integration testing with Test kitchen and unit testing with chefspec ?
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.
Test Kitchen can be used to write expectations about what will happen when a cookbook is deployed to what kind of system ?
A bare-metal machine
A cloud instance
A virtual instance
Any of the above
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 ?
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.
What is convergent ?
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.
What does the Supermarket do?
Acts as an artifact repository for Chef cookbooks and tools.
Both public and private repositories for Chef cookbooks and tools utilize Supermarket.
Which of these tools is not part of the Chef Development Kit?
Ruby
Kitchen
The Chef Server
The Chef Client
The Chef Server
What is the role of Test Kitchen (or just Kitchen) in automated testing?
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.
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
knife node list
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.
Using the chef generate repo command.
By generating a Chef repo “starter kit” from the Chef Server.
What is the name of the utility that provides a web user interface for a Chef Server?
Chef Manage
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.
The knife bootstrap command.
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
test-and-repair
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.
It can only contain lowercase letters, digits, hyphens, and underscores.
Default Resource Actions
: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 many Attribute types are there in chef ? what are they ?
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 can we define the attributes ?
Attributes are defined by:
The state of the node itself Cookbooks (in attribute files and/or recipes) Roles Environments Policyfiles
How to include a recipe into another recipe ?
include_recipe ‘cookbook::recipe’
Example:
include_recipe ‘base1::install’
include_recipe ‘base2::configure’
What indexes are available for chef search ?
Clients Nodes Environments Roles Databags(searchable individual)
What type of items can a run-list contains ?
Roles and Recipes
Where can attributes be set ?
Automatically(by ohai) and in recipes, nodes, roles and environments.
What chef package runs on nodes managed by chef to pull updated configuration ?
The chef-client
What does an environment consist of ?
A name, optional description, and optional list of cookbook versions.
What chef package will you use on your workstation ?
Chef DK Kit
What chef CLI command will create a new cookbook ?
chef generate cookbook
EX:
chef generate cookbook /home/karthi/chef-repo/cookbooks/base
What does Test kitchen do ?
Test kitchen provides a test harness for running integration tests for configuration policies.