Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Chef - Search

In this lab, we will demonstrate an understanding of Chef search in a recipe. First, we are going to install the ChefDK tools on a server, make sure Docker is working, and ensure Git is installed and has some basic configuration. We will then create a cookbook and recipe that utilizes the search function to look for users in a provided data bag. There will be a group created for the users our recipe finds. By the end of this hands-on lab, you will have installed and ChefDK tools, as well as have a working cookbook. We'll perform any testing by using `docker` and `kitchen` commands.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Jul 27, 2025
Duration
1h 0m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    On the Provided Server, Install Version 2.4.17 of the ChefDK Tools
    1. Download and install the 2.4.17 version of ChefDK at the command line.
    2. Once it's installed, make sure Chef uses the correct system locations.
    3. Verify it worked.
  2. Challenge

    Install What docker-ce Requires on This Server
    1. Install yum-utils.
    2. Add the Docker repository.
    3. Install Docker.
    4. Set Docker to start now and on system boot.
    5. Set your user to be able to use Docker without using the sudo command.
    6. Log out and back in again
    7. Check to make sure Docker is running.
      • If you can do that without prefacing it with sudo, you're ready to continue.
  3. Challenge

    Install Git and Set Some Global Defaults for Our User, Email Address, and Editor

    When we use Kitchen, later in the lab, we need Git to be installed and set up with some basic information.

    1. Install Git.
    2. Configure some Git basics:
      • Username (Your name)
      • Email address (This can be fake since we don't actually need it for the lab)
      • Default text editor (Vim)
  4. Challenge

    Install the Gem Required for Using Docker with the Test Kitchen

    Install the gem that Docker requires for this all to work.

  5. Challenge

    Update SELinux to Be Permissive
    1. Run a command to change SELinux so it is permissive.
    2. Open /etc/selinux/config.
    3. Change the SELINUX line from SELINUX=enforcing to SELINUX=permissive.
  6. Challenge

    Create a Cookbook Called la_search Then Move into That Folder
    1. Create a new cookbook called la_search.
    2. Change directory into la_search.
  7. Challenge

    Modify Our Kitchen File
    1. Open kitchen.yml.

    2. In the driver section replace vagrant with docker.

    3. At the bottom of the driver section, add the following (to be in line with the name line):

      privilege: true
      use_sudo: false
      
    4. In the provisioner section, add the following: a name and version as well as a reference to the data_bags location (it should all be in line with the name line):

      product_name: "chef"
      product_version: "13.8.5"
      data_bags_path: /home/cloud_user/chef/data_bags
      
    5. We're on a CentOS machine, so we need to get rid of ubuntu from the file. Delete (or comment out) the line in the platforms section that reads - name: ubuntu-16.04.

  8. Challenge

    Edit Our Recipe

    We need to get the recipe in a state that will do that administrators user installation, if there's not already such a user.

    1. Edit the recipes/default.rb file.

    2. Add these contents below the existing comment lines:

      admins = data_bag('admins')
      
      search(:admins, "gid:administrators").each do |admin|
      
        group admin['gid']
        login = admin["id"]
        admins << login
        home = "/home/#{login}"
      
        user(login) do
          uid admin['uid']
          gid admin['gid']
          shell admin['shell']
          comment admin['comment']
          home home
          manage_home true
        end
      end
      
  9. Challenge

    Build the Kitchen with Our Recipe

    Ensure it all works with kitchen converge. If all goes well, keep going. If not, troubleshoot any typos that may exist.

  10. Challenge

    Test by Logging Into the Kitchen
    1. Log in to the kitchen.
    2. View the contents of /etc/group.
      • We should see an administrators group.
    3. View the contents of /etc/passwd.
      • We should see mike was added in as a user.
  11. Challenge

    Clean up Any Instances That Have Been Created
    1. Log out of the enviroment using exit.
    2. Use kitchen destroy to clean up what we just created.
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight