Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are people testing opsworks cookbooks?

Tags:

I have a fairly complex deployment of dynamically configured instances of a rail apps on nginx using passenger that I currently use Capistrano for. I am trying to automate the entire process on Opsworks from creating the stack, layers, instances and dynamic app deployment. None of the existing Opsworks recipes come close to what I need so I started my own custom cookbooks. I am trying to test them using test-kitchen and vagrant but the Opsworks cookbooks have too many custom dependancies to be used locally. So it seems like I am stuck either re-inventing the wheel by using only my own recipes that don't depend on Opsworks cookbooks or trying to test my cookbooks on AWS which is slow and expensive.

Is anybody doing any custom cookbook development on Opsworks and if so how are you testing it? Are you using any community cookbooks and if so how painful have they been to get working on Opsworks?

like image 214
John Lemp Avatar asked Mar 24 '14 11:03

John Lemp


People also ask

What language is used to create recipes AWS OpsWorks?

A recipe is a Ruby application that uses Chef's domain-specific language (DSL) to describe the final state of the instance. With AWS OpsWorks Stacks, each recipe is usually assigned to one of the layer's lifecycle events: Setup, Configuration, Deploy, Undeploy, and Shutdown.

Which are the two options available for a customer in the Chef service of OpsWorks?

OpsWorks lets you use Chef and Puppet to automate how servers are configured, deployed, and managed across your Amazon EC2 instances or on-premises compute environments. OpsWorks has three offerings, AWS Opsworks for Chef Automate, AWS OpsWorks for Puppet Enterprise, and AWS OpsWorks Stacks.

What is an OpsWorks recipe?

Recipes are Ruby applications that define a system's configuration. They install packages, create configuration files from templates, execute shell commands, create files and directories, and so on.


2 Answers

Opsworks now supports Chef 11.10 and Berkshelf (http://berkshelf.com/) to manage dependencies which makes using custom cookbooks so. much. easier.

I've been pretty happy with Test Kitchen (https://github.com/test-kitchen/test-kitchen) with Vagrant & Chef Solo for local testing.

Additionally you can manually run particular recipes on an Opsworks stack from the stack settings page. Have a look here: http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-manual.html.

You can also run cookbook tests during an Opsworks deployment with some custom JSON: http://docs.aws.amazon.com/opsworks/latest/userguide/troubleshoot-debug-test.html

like image 107
imgrgry Avatar answered Sep 17 '22 11:09

imgrgry


We are using Opsworks with a lot of custom cookbooks, and vagrant as well. While the test-coverage is far from perfect, it works pretty smooth, adapting community cookbooks as well. Our cookbook repository is public: https://github.com/till/easybib-cookbooks

The interesting bits of this repo are:

  • We use a role-recipe as the entry point for each layer instead of specifiying multiple recipes with the layer in opsworks: https://github.com/till/easybib-cookbooks/blob/master/easybib/recipes/role-nginxapp-api.rb
  • We check if the recipe run is in AWS or in Vagrant using a custom library function: https://github.com/till/easybib-cookbooks/blob/master/easybib/libraries/easybib.rb#L208-L216
  • All opsworks-specific cookbooks/providers are usually only used in the deploy-cookbook, which we only include when is_aws is true, otherwise we fall back for a default application deployment.

Browsing our cookbooks should give you some more hints for your questions. We test our cookbooks with Travis, and do not test the opsworks cookbooks at all. Although I have to note that I am currently playing around there with some ideas how to integrate them in our test runs, since without their providers, testing our deploy cookbook is pretty much impossible.

like image 34
Florian Holzhauer Avatar answered Sep 19 '22 11:09

Florian Holzhauer