This is experimental repository for myself to try building infrastructure with TDD style using Chef.
- knife test for ruby syntax check
- foodcritic for lint
- chefspec for unit-test
Use Test-kitchen
- Drivers
- Bussers
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
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
Create initial Guardfile with guard-rake.
$ bundle exec guard init rake
While creating rules, refered guard-chef.
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