@nathenharvey
Introduction to Test Kitchen
@nathenharvey
Hello!
Nathen Harvey
VP, Community
Development
Chef
@nathenharvey
@nathenharvey
Why Testing?
• Move fast with a safety net
• Decrease feedback cycles
• Increase confidence
• Prevent regressions
• Scale
@nathenharvey
Developing Infrastructure Automation
• Write the automation
• Static analysis
• Unit testing
• Integration testing
• Commit to version control
• Submit to pipeline
@nathenharvey
Zoom-in on Integration Testing
• Create infrastructure that matches production
• Run the automation
• Verify the results
• Destroy the infrastructure
@nathenharvey
Test Kitchen
Test harness to execute
infrastructure code on one or
more platforms in isolation.
@nathenharvey
Before we continue…
$ kitchen verify -c 2
@nathenharvey
The Test Kitchen
platforms:
- name: ubuntu-16.04
- name: centos-7
platforms
@nathenharvey
The Test Kitchen
platforms:
- name: ubuntu-16.04
- name: centos-7
kitchen create
platforms
@nathenharvey
The Test Kitchen
driver:
name: gce
platforms:
- name: ubuntu-16.04
- name: centos-7
kitchen create driver
platforms
@nathenharvey
Zoom-in on Integration Testing
Create infrastructure that matches production
• Run the automation
• Verify the results
• Destroy the infrastructure
@nathenharvey
The Test Kitchen
driver:
name: vagrant
platforms:
- name: ubuntu-16.04
- name: centos-7
kitchen create driver
platforms
kitchen converge
@nathenharvey
The Test Kitchen
driver:
name: vagrant
platforms:
- name: ubuntu-16.04
- name: centos-7
provisioner:
name: chef_zero
kitchen create driver
platforms
kitchen converge provisioner
@nathenharvey
Chef Recipe
package 'git' do
action :install
end
@nathenharvey
Zoom-in on Integration Testing
Create infrastructure that matches production
Run the automation
• Verify the results
• Destroy the infrastructure
Introduction to Test Kitchen and InSpec
@nathenharvey
InSpec
• Open-source framework
• Infrastructure testing
• Make assertions about state of resources in the infrastructure
@nathenharvey
Sample InSpec Code
describe service('apache2') do
it { should be_running }
end
describe port(80) do
it { should be_listening }
end
describe http('http://localhost', enable_remote_worker: true) do
its('status') { should cmp 200 }
its('body') { should match /Welcome to / }
end
@nathenharvey
The Test Kitchen
driver:
name: vagrant
platforms:
- name: ubuntu-16.04
- name: centos-7
provisioner:
name: chef_zero
kitchen create driver
platforms
kitchen converge provisioner
kitchen verify
@nathenharvey
The Test Kitchen
driver:
name: vagrant
platforms:
- name: ubuntu-16.04
- name: centos-7
provisioner:
name: chef_zero
verifier:
name: inspec
kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
@nathenharvey
Verify the Results with InSpec
describe package('git') do
it { should be_installed }
end
describe command('git') do
it { should exist }
end
describe command('which git') do
its('exit_status') { should eq 0 }
end
@nathenharvey
Zoom-in on Integration Testing
Create infrastructure that matches production
Run the automation
Verify the results
• Destroy the infrastructure
@nathenharvey
The Test Kitchen
driver:
name: vagrant
platforms:
- name: ubuntu-16.04
- name: centos-7
provisioner:
name: chef_zero
verifier:
name: inspec
kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
Zoom-in on Integration Testing
Create infrastructure that matches production
Run the automation
Verify the results
Destroy the infrastructure
@nathenharvey
The Test Kitchen
kitchen test kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
The Test Kitchen
kitchen destroy
kitchen test kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
The Test Kitchen
kitchen destroy
kitchen create
kitchen test kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
The Test Kitchen
kitchen destroy
kitchen create
kitchen converge
kitchen test kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
The Test Kitchen
kitchen destroy
kitchen create
kitchen converge
kitchen verify
kitchen test kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
@nathenharvey
The Test Kitchen
kitchen create driver
platforms
kitchen converge provisioner
kitchen verify verifier
kitchen destroy
kitchen destroy
kitchen create
kitchen converge
kitchen verify
kitchen destroy
kitchen test
@nathenharvey
More Test Kitchen <3
@nathenharvey
The Test Kitchen
driver:
name: kitchen create driver
@nathenharvey
Remember this?
$ kitchen verify -c 2
Let’s go check-in on it…
$ kitchen list
@nathenharvey
Kitchen List
@nathenharvey
The Test Kitchen
provisioner:
name:
kitchen converge provisioner
@nathenharvey
The Test Kitchen
verifier:
name:
kitchen verify verifier
@nathenharvey
Compliance Testing
@nathenharvey
@nathenharvey
InSpec to Detect Policy Violations
• InSpec is great for integration testing
• But it can also be used for security or compliance checks
Automate Test Execution
describe ini('/etc/tac_plus/tac_plus.conf') do
its('key') { should_not be_nil }
end
404.3.5:
Communication
between network
devices and central
authentication systems
must be encrypted at
all times.
Map Documentation to Controls
control 'sox-404.3.5' do
title 'Network Device to Central Auth Encryption'
impact 1.0
desc "
All communication between network devices and
central auth must be encrypted. Our TACACS+ servers
encrypt all the time and the presence of a
pre-shared key proves it."
describe ini('/etc/tac_plus/tac_plus.conf') do
its('key') { should_not be_nil }
end
end
404.3.5:
Communication
between network
devices and central
authentication systems
must be encrypted at
all times.
Share Context
control 'sox-404.3.5' do
title 'Network Device to Central Auth Encryption'
impact 1.0
desc "
All communication between network devices and
central auth must be encrypted. Our TACACS+ servers
encrypt all the time and the presence of a
pre-shared key proves it."
describe ini('/etc/tac_plus/tac_plus.conf') do
its('key') { should_not be_nil }
end
end
404.3.5:
Communication
between network
devices and central
authentication systems
must be encrypted at
all times.
@nathenharvey
dev-sec.io
@nathenharvey
Add Linux Baseline to Test Kitchen
suites:
- name: default
verifier:
inspec_tests:
- test/integration/default
- https://github.com/dev-sec/linux-baseline
@nathenharvey
So many failures
• Stop when the build breaks
• We need to get to green
• What is the best way to get the build green?
@nathenharvey
Wrap it up
• Create a TODO list
• One measure of technical debt
• Get to green by commenting out tests?!
@nathenharvey
Wrapper Profile
name: my-linux-baseline
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: you@example.com
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
depends:
- name: linux-baseline
url: https://github.com/dev-sec/linux-baseline/archive/master.tar.gz
@nathenharvey
Wrapper Profile
include_controls 'linux-baseline' do
skip_control 'os-05'
skip_control 'package-08'
skip_control 'sysctl-05'
...
end
@nathenharvey
Hardening Playbook
@nathenharvey
- hosts: all
become: true
become_user: root
become_method: sudo
roles:
- { role: apache }
- { role: dev-sec.os-hardening }
Add to the Playbook
@nathenharvey
One Commit
@nathenharvey
@nathenharvey
@nathenharvey
Use InSpec to Verify Terraform-created Infrastructure
https://www.slideshare.net/nathenharvey/testing-terraform-102777946
Introduction to Test Kitchen and InSpec
@nathenharvey
September 10 & 11
@nathenharvey
@nathenharvey
@nathenharvey
Get Started with Test Kitchen
• Install Chef Development Kit - https://downloads.chef.io/chefdk
Test Kitchen
InSpec
• Install Driver Requirements
Vagrant – VirtualBox & Vagrant
Docker – Docker
GCE – None, but best to Google Cloud SDK installed
EC2 – None, but you need an AWS account
@nathenharvey
Use, Share, Contribute!
• Test Kitchen
https://kitchen.ci/
https://github.com/test-kitchen
• InSpec
https://www.inspec.io/
https://github.com/chef/inspec
• Code from this presentation
https://github.com/nathenharvey/intro-to-test-kitchen
https://github.com/nathenharvey/testing-ansible-with-inspec
https://github.com/nathenharvey/testing-terraform
@nathenharvey
Join us on Slack
• http://community-slack.chef.io
• #general (for Chef stuff)
• #test-kitchen
• #inspec
The Chef community
believes that diversity is one
of our biggest strengths!
YOU are welcome here!
@nathenharvey
Local Technology Slacks
• Baltimore
https://baltimoretech-slack.herokuapp.com/
• Washington DC
http://www.dctechslack.com/
Join a local technology
slack, or two, to help
maintain connections across
the community!
@nathenharvey
What questions can I answer for you?
Nathen Harvey
VP, Community
Development
Chef
@nathenharvey

More Related Content

PPTX
Effective Testing with Ansible and InSpec
PPTX
Introduction to Test Kitchen
PPTX
Effective Testing with Ansible and InSpec
PDF
Bay Area Chef Meetup February
PPTX
Drupal Continuous Integration with Jenkins - The Basics
PDF
Game of Codes: the Battle for CI
PDF
At Your Service: Using Jenkins in Operations
PDF
DevOp with Me!
Effective Testing with Ansible and InSpec
Introduction to Test Kitchen
Effective Testing with Ansible and InSpec
Bay Area Chef Meetup February
Drupal Continuous Integration with Jenkins - The Basics
Game of Codes: the Battle for CI
At Your Service: Using Jenkins in Operations
DevOp with Me!

What's hot (20)

PDF
Introduction to Infrastructure as Code & Automation / Introduction to Chef
ZIP
Drupal Deployment
PDF
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
PPTX
Automated Infrastructure Testing
PDF
Prescriptive System Security with InSpec
PDF
Intermediate/Compliance training Guide
PDF
Rise of the Machines - Automate your Development
PPTX
Automated Deployments
PDF
Drone your Ansible
PDF
Testing programmable infrastructure
PPTX
Testing for infra code using test-kitchen,docker,chef
PPTX
How to Write Chef Cookbook
PDF
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
PPTX
London Community Summit - Chef at SkyBet
PDF
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
PPTX
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
PPTX
Compliance Automation with Inspec Part 4
PDF
Docker and Puppet for Continuous Integration
PDF
Test Driven Development with Chef
ODP
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Drupal Deployment
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
Automated Infrastructure Testing
Prescriptive System Security with InSpec
Intermediate/Compliance training Guide
Rise of the Machines - Automate your Development
Automated Deployments
Drone your Ansible
Testing programmable infrastructure
Testing for infra code using test-kitchen,docker,chef
How to Write Chef Cookbook
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
London Community Summit - Chef at SkyBet
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Compliance Automation with Inspec Part 4
Docker and Puppet for Continuous Integration
Test Driven Development with Chef
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Ad

Similar to Introduction to Test Kitchen and InSpec (20)

PDF
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
PPTX
Using Chef InSpec for Infrastructure Security
PPTX
InSpec at DevOps ATL Meetup January 22, 2020
PPTX
Prescriptive Security with InSpec - All Things Open 2019
PDF
Testable Infrastructure with Chef, Test Kitchen, and Docker
PDF
Test Kitchen and Infrastructure as Code
PDF
Ansible, integration testing, and you.
PDF
Terraform Testing with InSpec Demo
PPTX
2019 Chef InSpec Jumpstart Part 1 of 2
PPTX
InSpec For DevOpsDays Amsterdam 2017
PDF
Philly security shell meetup
PPTX
DevSecCon London 2017: Inspec workshop by Mandi Walls
PPTX
InSpec Workshop DevSecCon 2017
PDF
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
PDF
2016 - Compliance as Code - InSpec
PDF
Compliance as Code
PDF
Automating Compliance with InSpec - Chef Singapore Meetup
PDF
Chef for beginners module 5
PPTX
Adding Security to Your Workflow With InSpec - SCaLE17x
PDF
Using Test Kitchen for testing Chef cookbooks
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
Using Chef InSpec for Infrastructure Security
InSpec at DevOps ATL Meetup January 22, 2020
Prescriptive Security with InSpec - All Things Open 2019
Testable Infrastructure with Chef, Test Kitchen, and Docker
Test Kitchen and Infrastructure as Code
Ansible, integration testing, and you.
Terraform Testing with InSpec Demo
2019 Chef InSpec Jumpstart Part 1 of 2
InSpec For DevOpsDays Amsterdam 2017
Philly security shell meetup
DevSecCon London 2017: Inspec workshop by Mandi Walls
InSpec Workshop DevSecCon 2017
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
2016 - Compliance as Code - InSpec
Compliance as Code
Automating Compliance with InSpec - Chef Singapore Meetup
Chef for beginners module 5
Adding Security to Your Workflow With InSpec - SCaLE17x
Using Test Kitchen for testing Chef cookbooks
Ad

More from Nathen Harvey (9)

PDF
Accelerate Your DevOps Journey
PDF
Continuous Delivery - GDG Cloud Baltimore
PDF
Using Error Budgets to Prioritize Work
PPTX
Testing Terraform
PDF
DevOps Days India Keynote
PPTX
Compliance Automation with InSpec
PDF
Step AFK: Practical Advice for Career Adavancement
PDF
Walk This Way - An Introduction to DevOps
PPTX
Mongo db at_customink
Accelerate Your DevOps Journey
Continuous Delivery - GDG Cloud Baltimore
Using Error Budgets to Prioritize Work
Testing Terraform
DevOps Days India Keynote
Compliance Automation with InSpec
Step AFK: Practical Advice for Career Adavancement
Walk This Way - An Introduction to DevOps
Mongo db at_customink

Recently uploaded (20)

PPT
What is a Computer? Input Devices /output devices
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPT
Geologic Time for studying geology for geologist
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Five Habits of High-Impact Board Members
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
What is a Computer? Input Devices /output devices
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Developing a website for English-speaking practice to English as a foreign la...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Module 1.ppt Iot fundamentals and Architecture
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Geologic Time for studying geology for geologist
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
Microsoft Excel 365/2024 Beginner's training
sustainability-14-14877-v2.pddhzftheheeeee
Getting started with AI Agents and Multi-Agent Systems
Abstractive summarization using multilingual text-to-text transfer transforme...
CloudStack 4.21: First Look Webinar slides
OpenACC and Open Hackathons Monthly Highlights July 2025
Flame analysis and combustion estimation using large language and vision assi...
Five Habits of High-Impact Board Members
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
1 - Historical Antecedents, Social Consideration.pdf
Enhancing emotion recognition model for a student engagement use case through...

Introduction to Test Kitchen and InSpec