Automate and scale your infrastructure with Chef
Interviewed by Christophe Limpalair on 05/13/2015
Nathen is a talented teacher. When he explains a concept, it just makes sense to me. In this episode he shows us how to get started with Chef, and I'm really curious to see if his teaching style has the same effect for you.
I had a few viewers talk about Chef vs. Ansible after Chris Fidao's Interview, and some were a bit overwhelmed by Chef at first sight. So I asked Nathen to come on the show and give us a bit more clarity on what Chef is and how to get started with it.
All the code used in the interview is available on github.
Looking for the hilarious videos we mentioned in the interview?
Chef vs. Ansible, Puppet, etc..?
Starts at 8:58 in the interview.
Nathen's answer: You should absolutely use one of the frameworks instead of banging on your keyboard with shell scripts.
Already using one and it works perfectly fine for what you're doing? Stick to it.
Chef offers a full set of tools that will enable a full DevOps workflow-- It starts with the basics of configuration management and then includes provisioning for servers. On top of that, Chef has a lot of very powerful tools for testing your infrastructure code so you can run tests before using it on your production system.
Is Chef only for large scale apps?
Starts at 17:31 in the interview.
No. Even if you have just one server, Chef can rebuild it for you and scale it out.
By the way, Chef could also be used for your computer-- not just web apps. (18:13 in the interview)
Is Chef hard to learn?
Starts at 12:24 in the interview.
When you learn a new programming language, you usually start with a "Hello Word" application and then go from there. You should do the same when starting with Chef, because it's kind of like learning a new language. Managing complex systems is not an easy job, but start with the basics and work your way up.
Then you can take something you want to automate in your infrastructure and play around with Chef to make it work. Like everything else, practice will make you learn.
Even though Chef uses a lot of Ruby, it's really not bad when you first start with the basics. Nathen adds that when you're ready to build more complex configurations, the full power of Ruby is at your fingertips. Not knowing Ruby is not a deal breaker.
To get started with Chef, here are a few resources:
Starts at 19:57 in the interview.
Starts at 28:46 in the interview.
Nathen shows how to get started with the ChefDK and creating a repository.
Hello World with Unit Tests
Starts at 31:18 in the interview.
Spin up a Virtual Environment to test with Test Kitchen
Starts at 34:10 in the interview.
I was amazed at how easy it was to set this up.
This can be done locally, or it could also run on an Amazon EC2 instance, DigitalOcean Droplet, etc.. Here's a $10 credit from DigitalOcean through my referral link. That will give you 2 months free for 512 MB of RAM, or 1 month free for 1GB.
Webserver Installation Test
Starts at 43:10 in the interview.
Write a recipe to install a Webserver
Starts at 46:46 in the interview.
Use cookbooks as dependencies with Berkshelf
Starts at 49:15 in the interview.
With Berkshelf, you can load cookbook dependencies. Cookbooks can do anything from installing packages and running them, to updating your apt cache before downloading packages, etc... Being able to load them from the Chef Supermarket can save you a lot of time.
Even though cookbooks come pre-configured, you can tweak different settings to fit your needs with recipes. This makes the framework very flexible.
What to do next to keep learning?
Starts at 52:25 in the interview.
Look at existing cookbooks from the supermarket, learn from them, and write your own. You can also look at recipes and using them to tweak configurations and add more functionality. Then you can also take a look at templates. (Templates explained at 53:03 in the interview)
Nathen also offered to come back on the show and continue where we left off. If you'd like to see more advanced Chef, leave a comment below!
Thanks for watching!
Get in touch with Nathen on Twitter at @nathenharvey and let us know what you think about this interview in the comments below!
How did this interview help you?
If you learned anything from this interview, please thank our guest for their time.
Oh, and help your followers learn by clicking the Tweet button below :)