1
End to End Immutable
Infrastructure Testing
January 2020
© 2019 Nebulaworks, Inc.
2
So there I was...
3
HI, MY NAME IS DREW
4
OVERVIEW
Tell & Show:
- why: testing
- what: is/are we testing
- how: demo
- questions
ASSUMPTIONS
Good at:
- config mgmt
- deployment via code
- Packer
- git
Know some about:
- Continuous Integration
- Terraform
- Vagrant
- Azure
- Immutable Infrastructure
5
WHY TESTING? (engineer version)
Code change
Developers change
Dependencies change
Testing is about taking back control
6
WHY TESTING? ( manager version)
deployment confidence -> reduced stress
short-lived development environments
documents your infrastructure
ease of refactoring
Testing is about reducing risk
7
ALTERNATE PRESENTATION NAMES
Technically coping with change: a memoir
How I sleep at night (as a infra. eng.)
Cowboy deploy to tried and tested
8
4 KINDS OF TESTS
●
●
●
●
9
PARTICIPATION AWARD
YOU
CONGRATULATIONS <YOUR NAME>!
10
4 KINDS OF INFRASTRUCTURE TESTS
1. Eyeballing it
2. Linting
3. Unit Testing
4. Integration Testing
you, a scientist,
eyeballing it
BEFORE your code merges
BEFORE your code runs
AFTER your code runs
1. Eyeballing it
11
OVERVIEW
feedback
loop
Local CI
Post
Deployment
12
TOOLS
Goss (no cool logo) Terratest (no cool logo)
RSpec
(not a cool logo)
Inspec
“The Specs”
IN
SPEC
FACTS
Ruby Gem Developed by
Chef
Native integrations with:
- Packer
- Ansible Molecule
- Chef Suite
Cloud Resource Testing!
13
PROFILE a distinct module of inspec code
CONTROL a single or grouping of distinct tests
RESOURCE the inspec resource with properties to verify
MATCHER used to compare resource values to expectations
TARGETS native connection / auth methods to launch tests
INSPEC PRIMER
control ‘tmp’ do
title ’Verify /tmp exists’
desc 'A detailed description'
describe file('/tmp') do
it { should be_directory }
end
end
control ‘home’ do
title ’Verify /home exists’
...
Profile
inspec exec my-azure-profile -t azure://<subscription_id>
inspec exec my-vm-ssh-profile -t ssh://user@ip:port
14
DEMO TIME!
SHUT UP!
15
RETROSPECTIVE
16
WHAT NEXT?
1. Use your eyeballing tests
2. Write a test for every configuration change you make. Every one
3. Think and talk about it with your team and write more tests
4. Write tests for things that you miss
5. Seek guidance from compliance and security teams, partner with them (do at your own peril)
6. Rely upon external profiles and open-source yours
https://github.com/dev-sec/linux-baseline/releases
Start writing tests!
Important: Don’t merge code without tests
17
THANK YOU!
QUESTIONS?
email: drew@nebulaworks.com
code & slides: https://github.com/drewmullen/infra-testing-demo

End to End immutable infrastructure testing

  • 1.
    1 End to EndImmutable Infrastructure Testing January 2020 © 2019 Nebulaworks, Inc.
  • 2.
  • 3.
  • 4.
    4 OVERVIEW Tell & Show: -why: testing - what: is/are we testing - how: demo - questions ASSUMPTIONS Good at: - config mgmt - deployment via code - Packer - git Know some about: - Continuous Integration - Terraform - Vagrant - Azure - Immutable Infrastructure
  • 5.
    5 WHY TESTING? (engineerversion) Code change Developers change Dependencies change Testing is about taking back control
  • 6.
    6 WHY TESTING? (manager version) deployment confidence -> reduced stress short-lived development environments documents your infrastructure ease of refactoring Testing is about reducing risk
  • 7.
    7 ALTERNATE PRESENTATION NAMES Technicallycoping with change: a memoir How I sleep at night (as a infra. eng.) Cowboy deploy to tried and tested
  • 8.
    8 4 KINDS OFTESTS ● ● ● ●
  • 9.
  • 10.
    10 4 KINDS OFINFRASTRUCTURE TESTS 1. Eyeballing it 2. Linting 3. Unit Testing 4. Integration Testing you, a scientist, eyeballing it BEFORE your code merges BEFORE your code runs AFTER your code runs 1. Eyeballing it
  • 11.
  • 12.
    12 TOOLS Goss (no coollogo) Terratest (no cool logo) RSpec (not a cool logo) Inspec “The Specs” IN SPEC FACTS Ruby Gem Developed by Chef Native integrations with: - Packer - Ansible Molecule - Chef Suite Cloud Resource Testing!
  • 13.
    13 PROFILE a distinctmodule of inspec code CONTROL a single or grouping of distinct tests RESOURCE the inspec resource with properties to verify MATCHER used to compare resource values to expectations TARGETS native connection / auth methods to launch tests INSPEC PRIMER control ‘tmp’ do title ’Verify /tmp exists’ desc 'A detailed description' describe file('/tmp') do it { should be_directory } end end control ‘home’ do title ’Verify /home exists’ ... Profile inspec exec my-azure-profile -t azure://<subscription_id> inspec exec my-vm-ssh-profile -t ssh://user@ip:port
  • 14.
  • 15.
  • 16.
    16 WHAT NEXT? 1. Useyour eyeballing tests 2. Write a test for every configuration change you make. Every one 3. Think and talk about it with your team and write more tests 4. Write tests for things that you miss 5. Seek guidance from compliance and security teams, partner with them (do at your own peril) 6. Rely upon external profiles and open-source yours https://github.com/dev-sec/linux-baseline/releases Start writing tests! Important: Don’t merge code without tests
  • 17.
    17 THANK YOU! QUESTIONS? email: drew@nebulaworks.com code& slides: https://github.com/drewmullen/infra-testing-demo