Good News Everyone,
The Joy of Automating is an hour-long, instructional LIVE show hosted by me. In each episode, we will build a cookbook or add features to an existing cookbook while we share techniques on workflow, testing, and debugging. The focus is on honing ones skill through practice and repetition while exploring the richness of code.
Come! Be part of this community! Bring your keyboard, the Chef DK, and your knowledge!
When: Fridays @ 10AM PDT
Watch the first episode: https://www.youtube.com/watch?v=FOYc_SGWE-0&list=PL11cZfNdwNyORJfIYA8t07PRMchyDXIjq
Episode 2 is available: https://www.youtube.com/watch?v=vEfMLejGhS4
In this episode we focused on converting the installation of Django into tested recipes. We explored installing Django from multiple sources: packages; pip; and through virtualenv. Which lead us into writing integration tests and unit tests for the various recipes, defining multiple test kitchen suites, and git branch workflow. Near the end we started to define a custom resource within the cookbook to handle our requests to install packages through pip. You can review the activity and the code generated here: https://github.com/chef-training/joy_of_automating.
Episode 3 is available: https://www.youtube.com/watch?v=Td1MMyvwaF8
In this episode we focused on working with legacy code. Legacy code is everywhere. Learning the steps to tackle this kind of work essential. This is a cookbook that deploys Redis on Ubuntu. We wrote an integration test that exposed some issues in the recipe. Then proceeded to write unit tests to capture the current state. The resources used a lot of notifications to generate a chain of events that were important to test. Near the end we refactored out the version into a node attribute and then started to refactor the resource names to make the specifications less brittle. We finished with starting to apply the same refactoring techniques to our test suite.
Episode 4 is available: https://learn-acceptance.chef.io/skills/joy-of-automating-episode-4/
In this episode we focus on working with converting a script to a recipe and then refactor that recipe to use Chef community cookbooks. We started with an integration test and initial implementation. There were some problems with the package installation of Jenkins that we were able to discover by searching for the issue. We then opened up the Jenkins community cookbook to compare our implementations and saw the
apt_repository resource being used. We setup the cookbook dependency on the apt cookbook and was able to simplify our implementation. Then with the remaining minutes we explored the
apt_repository implementation using Pry… Pry is a breakpoint debugger that allowed us to perform some introspection on the code and investigate what exactly was happening at runtime.
Episode 5 is available: https://learn.chef.io/skills/joy-of-automating-episode-5/
In this episode we focus on refactoring the test suite defined for a cookbook. Using a little Ruby and a lot of RSpec’s powerful features we are able to make a clearer and concise test suite. I have quite a bit of Ruby and RSpec experience so I really explored a lot of the helper methods like
shared_context, and aliasing.