Installing the Chef Development kit and Puppet Collections

The Chef ecosystem is as rich as Chef itself is complex; there's a myriad of tools filling almost every imaginable task we can think of. Chef being written in Ruby, a lot of those tools are also written in Ruby and over the years, the usual dependency hell between tools, plugins, code, and various Ruby versions led to a simple solution—the Chef DK. The Chef DK also brings a nice selection of the best tools and environments that work well together.

We'll see how to install the Chef DK and quickly describe what it includes.

Note

The current Chef DK version is 1.1.16.

Getting ready

To work through this recipe, you will need the following:

  • An Internet connection
  • A physical or virtual machine

How to do it…

The Chef DK can be downloaded from https://downloads.chef.io/chef-dk/. There're versions for most platforms: Debian, Red Hat-based systems, Ubuntu, and Windows. Simply download the package corresponding to your platform and install it. For example, using a recent Fedora, and installing the Red Hat package, the installation goes like this:

$ sudo dnf install chefdk-1.1.16-1.el7.x86_64.rpm

Verify the installation worked as expected:

$ chef --version
Chef Development Kit Version: 1.1.16

That's it! Everything we need to start coding Chef recipes is there.

Chef DK contents

The Chef DK includes a selection of the best tools, including the following:

  • Chef: A workflow tool
  • Berkshelf: A cookbook dependency manager that does a lot more than that
  • Test Kitchen: A full featured integration tests framework
  • ChefSpec: easy unit testing of Chef code
  • FoodCritic: static code analysis for quality and consistency

The Chef DK also includes all the standard Chef commands (chef-solo or chef-client to apply cookbooks on nodes, or knife to manipulate Chef resources on the developer's workstation, among other tools).

How it works…

The whole Chef environment, as well as its dependencies is deployed under /opt/chefdk. The package we installed created symlinks from this directory to /usr/bin which is on the $PATH:

$ ls -al /usr/bin/chef
lrwxrwxrwx. 1 root root 20 Oct  5 16:36 /usr/bin/chef -> /opt/chefdk/bin/chef

This way of packaging software includes all its dependencies, and as Chef relies heavily on Ruby, the Chef DK ships with an embedded version that does not conflict with a Ruby version that might already be installed on your system:

$ /opt/chefdk/embedded/bin/ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

There's more…

Starting from Puppet 4.x, Puppet Labs is providing repositories for both agent and server packages. These repositories are called Puppet Collections. As for Chef, provided packages are shipped with an Embedded Ruby version.

All examples from this book have been developed with Puppet 4.8 (open source edition). Packages can be downloaded from https://docs.puppet.com/puppet/4.8/puppet_collections.html.

First of all you need to install the puppet-agent package from Puppet Collections on your workstation. Even if we won't be managing it using Puppet, these packages will install some commands necessary for upcoming examples.

Once the package is installed, all files are deployed under /opt/puppetlabs:

$ ls -la /opt/puppetlabs/bin/puppet
lrwxrwxrwx 1 root root 20 Sep 22 18:42 /opt/puppetlabs/bin/puppet -> ../puppet/bin/puppet
$ /opt/puppetlabs/puppet/bin/ruby -version
ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux]

For an easier use of the Embedded Ruby version, you need to add /opt/puppetlabs/puppet/bin to the $PATH environment variable. For example, on Linux systems, this can be done by appending the following line in the .bashrc file located in your home directory:

export PATH=/opt/puppetlabs/puppet/bin:$PATH

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.85.33