Skip to content

tcnksm-sample/test-driven-development-chef-cookbook

Repository files navigation

Test Driven Infrastructure

Build Status

What is this ?

This is experimental repository for myself to try building infrastructure with TDD style using Chef.

Overview

Static test

Dynamic test

Use Test-kitchen

How to create cookbook

Setup

At first, install all dependencies

$ bundle install --path vendor/bundle --binstubs .bundle/bin

Create .env file for kitchen-digitalocean secret key.

DIGITALOCEAN_CLIENT_ID: ""
DIGITALOCEAN_API_KEY: ""
SSH_KEY_IDS: ""

Enable dotenv in bin/kitchen

require 'dotenv'
Dotenv.load

Development

Run static test with guard

$ bundle exec guard

Create cookbook. By knife-spec, this also generate default chefspec tests.

$ bundle exec knife cookbook create httpd

Run dynamic (integrate) test at end.

$ bundle exec rake kitchen:all

How to start this repository

Guard

Create initial Guardfile with guard-rake.

$ bundle exec guard init rake

While creating rules, refered guard-chef.

Test-kitchen

Generating initial settings

$ bundle exec kitchen init -D kitchen-digitalocean

To use kitchen-digitalocean, we need to secret environmental varialbes like DIGITALOCEAN_CLIENT_ID. To handle it, use dotenv and create .env file. And also create rake tasks.

And setup serverspec for busser.

$ cd test/integration/default/
$ bundle exec serverspec-init
$ rm Rakefile
$ mv spec serverspec

About

Test Driven Infrastructure Development with Chef

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages