Learning Chef: A Configuration Management and Automation Framework
Mischa Taylor, Seth Vargo
Format: PDF / Kindle (mobi) / ePub
Solve configuration management issues in enterprises large and small with Chef, the software tool that helps system administrators unravel configuration problems and explore new avenues in automation, deployment, and orchestration. With this practical guide, you’ll quickly learn the basics of Chef before diving into complex use cases.
Not will this book enable you to solve detailed issues, such as the best way to manage 400 EC2 nodes, but it will also help you understand the changing organizational politics and thought-processes that come with infrastructure automation.
Gain a firm understanding of Chef: Who created it and what problems does it solve?
Set up your workstation and workflow: Installing Chef can be a headache. There's no prescribed workflow that’s useful for everyone.
Write custom recipes: Because every infrastructure is different, you may need to write a custom recipe. Writing good cookbooks is crucial for having a sustainable infrastructure.
Tailor Chef to your infrastructure: Eventually, even custom recipes won't be enough. You’ll want to extend the Chef’s core functionality.
hello.rb file and that it has the correct content: $ more hello.txt Welcome to Chef Verify Your First Chef Recipe | 57 Examine hello.rb Let’s go over each line in hello.rb from Example 4-1 in more detail, exploring the purpose of each component. As mentioned earlier, Chef code uses a domain-specific language (DSL) built on top of the Ruby programming language. Having expressions tailored for system administration makes Chef code more accessible to beginners. The DSL is also designed to make
platforms: - name: ubuntu-12.04 - name: centos-6.4 suites: - name: default Test Kitchen Configuration with .kitchen.yml | 81 run_list: attributes: The three hyphens at the beginning denote that kitchen.yml is a YAML file. The .kitchen.yml contains four main sections: driver: Specifies the driver plugin to use, plus configuration parameters to manage Test Kitchen environments. You can get a list of drivers running the command kitchen driver discover. We’re using the default driver
the file we want to create, not the path: $ chef generate file motd Compiling Cookbooks... Recipe: code_generator::cookbook_file * directory[/Users/misheska/learningchef/motd/files/default] action create - create new directory /Users/misheska/learningchef/motd/files/default * template[/Users/misheska/learningchef/motd/files/default/motd] action create - create new file /Users/misheska/learningchef/motd/files/default/motd - update content in file /Users/misheska/learningchef/motd/files/default
As shown in the following code block, we want to perform the :run action on the execute[chef-server-ctl reconfigure] resource, and we want the action performed :immediately. For more information on notifies param‐ eters, refer to the Chef documentation: package package_name do source package_local_path provider Chef::Provider::Package::Rpm notifies :run, 'execute[chef-server-ctl reconfigure]', :immediately end Example 9-4 shows what the final version of our idempotent code looks like. Example
beyond. Why Chef Might Be a Good Tool for Your Enterprise When Adam Jacob first created Chef in 2009, he had three key insights to address the shortcomings he saw in other configuration management tools: 1. A configuration management tool should easily enable web IT, providing first-class support for managing cloud infrastructure. 4 | Chapter 1: Configuration Management and Chef 2. Everyone’s infrastructure is unique. Complex, enterprise infrastructures benefit greatly from being able to