Press "Enter" to skip to content

Tag: Chef

Chef and Docker for a rapid infrastructure development

We started using Chef a while ago and one of the first steps we took was to use Docker instead of Vagrant for performing tests due to its faster setup.
After all this time I can say it was a nice experience and now our CI is happily testing out in minutes. So…

What do you need?

Basically, you need to install the latest ChefDK where the gem kitchen-dokken is installed by default. This gem enables lightweight tooling to use Docker containers for executing Kitchen.

Setup

After that, you just need to set up your kitchen.yml to use dokken as a driver like so:

---
driver:
  name: dokken
  chef_version: latest

transport:
  name: dokken

provisioner:
name: dokken

...

The transport and the provisioner are set to dokken so the kitchen will use the lighter tooling from the driver. Then you can set up your platform to test your cookbooks:

  - name: ubuntu-16.04
    driver:
      image: ubuntu:16.04
      pid_one_command: /bin/systemd
      intermediate_instructions:
        - RUN /usr/bin/apt-get update

Considerations

  • Docker is designed for isolating and packaging processes that run as the only process inside a container.
    If your cookbook setup services you may need to choose a complete Docker base image that normally is bigger in size, also you need to explicitly start the system daemon (such as systemd) as you saw on the code snippet earlier.
  • Do not try to run Docker inside a container. If your cookbook uses Docker somehow is better to use Vagrant instead because then you may need to manually set up the container to host docker and that is a pain.

DevOps with Chef. Sweet.

I needed to set up a few servers for QA and provision development environments for my team so I started a small make-based repo where to put all the nasty configuration and provisioning stuff. After a few days of work, I decided to look for solutions on the world wide web. Then discovered the DevOps discipline.

DevOps enlightened me. Is exactly what I was looking for!

I work in an industrial environment with real-time and embedded software using tools such as Yocto and scripting. Not related to web development at all and even less to cloud computing… So DevOps was quite far away from my environment, but as a curious guy I started diving into it: Ansible, Docker, Puppet, Salt… And finally, I looked into Chef.

Exactly what I was looking for.

Remember my objective: setting up some servers for QA and CI for my team and provisioning our developer environments with the proper tools. Well,  Chef is designed exactly for that!

Why Chef?

Ruby.

If you don’t know about Ruby, it is a small and nifty language. I recommend starting with the koans.

As a developer, having a language instead of some custom file syntax or an obscure engine is always a plus. Of course, you will have some drawbacks enforcing yourself to deal with infrastructure and setup, but depending on the size of your team, is something you may need to deal with it anyway.

If your team is not enlightened yet by DevOps something you will get from Chef among other similar tools are the DevOps mantras:

  • Environment replication.
  • Scalability.
  • Infrastructure as code. (Version controlled)
  • Quality and reliability.

And with Chef, as an open source project, you will also have lots and lots of community support and a complete community repository of recipes: The supermarket.

Where to start?

Is not in the scope of this blog entry to show Chef, but there is a lot of information in their learning portal and some nice books to start with. Is a matter of a couple of days to start doing Chef recipes and organizing your infrastructure just learning Ruby and having a nice introductory reading, I personally read Learning Chef.

Please, let me know if this information was helpful for you!