Slide 1

Slide 1 text

TEST DRIVEN INFRASTRUCTURE WITH CHEF DevOps meetup Würzburg 2017-09-12 Markus Heurung

Slide 2

Slide 2 text

$ whoami MARKUS HEURUNG > @muhh > [email protected] > Web Ops lead @freistil building freistilbox

Slide 3

Slide 3 text

TEST DRIVEN WHAT? @sadserver

Slide 4

Slide 4 text

TEST DRIVEN DEVELOPMENT 1. Write test 2. implement functionality 3. refactor

Slide 5

Slide 5 text

CHEFDK The Chef Development Kit is a package that contains everything that is needed to start using Chef1 1 https://docs.chef.io/workstation.html#chef-dk

Slide 6

Slide 6 text

CHEFDK > chef generate > rubocop > foodcritic > Berkshelf > serverspec > inspec > test-kitchen

Slide 7

Slide 7 text

chef generate cookbook devops_wue_tdi

Slide 8

Slide 8 text

RUBOCOP RuboCop is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.2 chef exec rubocop . 2 http://rubocop.readthedocs.io/

Slide 9

Slide 9 text

FOODCRITIC Foodcritic is a helpful lint tool you can use to check your Chef cookbooks for common problems.3 chef exec foodcritic . 3 http://foodcritic.io

Slide 10

Slide 10 text

BERKSHELF Berkshelf is a dependency manager for Chef cookbooks. With it, you can easily depend on community cookbooks and have them safely included in your workflow.4 4 http://berkshelf.com

Slide 11

Slide 11 text

CHEFSPEC ChefSpec is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.5 5 https://chefspec.github.io/chefspec/

Slide 12

Slide 12 text

SERVERSPEC RSpec tests for your servers configured by CFEngine, Puppet, Ansible, Itamae or anything else.6 6 http://serverspec.org

Slide 13

Slide 13 text

INSPEC InSpec is compliance as code7 7 https://www.inspec.io

Slide 14

Slide 14 text

TEST-KITCHEN Kitchen provides a test harness to execute infrastructure code on one or more platforms in isolation.8 8 http://kitchen.ci

Slide 15

Slide 15 text

.KITCHEN.YML --- driver: name: vagrant require_chef_omnibus: true provisioner: name: chef_zero verifier: name: inspec platforms: - name: ubuntu-16.04 - name: windows-2012r2 suites: - name: client run_list: - recipe[postgresql::client] - name: server run_list: - recipe[postgresql::server]

Slide 16

Slide 16 text

$ kitchen create $ kitchen converge $ kitchen setup $ kitchen verify $ kitchen destroy

Slide 17

Slide 17 text

$ kitchen test

Slide 18

Slide 18 text

LINKS > Repository zum Talk: gitlab.com/muhh/ devops_wue_tdi > Slides - Speakerdeck: speakerdeck.com/muhh

Slide 19

Slide 19 text

DEMO