Slide 1

Slide 1 text

© 2014 Cassini Consulting Andreas Schmidt Testing server infrastructure with serverspec

Slide 2

Slide 2 text

Cassini Consulting @cassinigmbh •  IT & Management Consulting Andreas Schmidt •  From Dev to Ops •  Infrastructure & Deployment Automation w/ ruby

Slide 3

Slide 3 text

•  Purpose of infrastructure testing •  #serverspec •  Examples / Demo •  Use Cases & benefits ? !

Slide 4

Slide 4 text

Provisioning & Delivery

Slide 5

Slide 5 text

Application being tested?

Slide 6

Slide 6 text

Servers being tested?

Slide 7

Slide 7 text

How is infrastructure being specified?

Slide 8

Slide 8 text

„Startup“ •  Recent cloud technology •  Virtual Infrastructure Provisioning •  „Phoenix Server“ „Classic“ IT Environments •  Both virtualized & non-virtualized •  Mixed Provisioning processes •  IT outsourcing •  IT System & Software Architecture Regulated IT Environments •  i.e. banking, insurance companies, government •  + Compliance •  + Security Low Cost Short Cycle Time Documentation (Internal/External) Audit Capabilities Internal Documentation Acceptance Tests

Slide 9

Slide 9 text

Automated Provisioning & Configuration Management

Slide 10

Slide 10 text

Lower-level configuration aspects •  VM infrastructure & kernel parameters •  Networking •  Logical volume management Side effects •  RPM post-install scripts Documentation •  Specification of infrastructure •  Human Readable Testing on machine itself what‘s missing?

Slide 11

Slide 11 text

Machine parse-able Human read-able Infrastructure Specification

Slide 12

Slide 12 text

serverspec •  www.serverspec.org •  github.com/serverspec/serverspec MIT License Gosuke Miyashita @gokusenator „With serverspec, you can write RSpec tests for checking your servers are configured correctly.“

Slide 13

Slide 13 text

serverspec describe package 'openssh-server' do it { should be_installed } end describe file '/etc/ssh/sshd_config' do it { should be_mode 600 } it { should be_owned_by 'root' }
 end describe service 'ssh' do it { should be_enabled } end

Slide 14

Slide 14 text

Development box CM code

Slide 15

Slide 15 text

Development box CM code CM code specs Test locally

Slide 16

Slide 16 text

Development box CM code Staging Provision CM code specs box „state“ Test locally

Slide 17

Slide 17 text

Development box CM code Staging Provision Test locally CM code specs box „state“ server spec „Spec“ box

Slide 18

Slide 18 text

Development box CM code Staging Provision Test locally CM code specs box „state“ Test on server(s) server spec „Spec“ box

Slide 19

Slide 19 text

Development box CM code Staging Local VM or Container Provision Test locally CM code specs box „state“ Provision Test on server(s) server spec „Spec“ box

Slide 20

Slide 20 text

Development box CM code Staging Local VM or Container Provision Test locally CM code specs box „state“ Test Provision Test on server(s) server spec „Spec“ box

Slide 21

Slide 21 text

Development box CM code Staging Local VM or Container Provision Test locally CM code specs box „state“ Test Provision Test on server(s) server spec „Spec“ box

Slide 22

Slide 22 text

$ gem install serverspec diff-lcs, highline, rake 
 net-ssh 
 rspec, rspec-core, rspec- expectations, rspec-mock 
 specinfra, serverspec Basics ssh to target hosts spec basics „Backend“ for infrastructure tests (local/remote, command abstraction, helpers) „Frontend“ w/ resource types à rspec

Slide 23

Slide 23 text

Demo •  Serverspec Basics •  Overview of resource types •  Using abstractions and facts •  Introduce roles •  Environment-independent specs through properties

Slide 24

Slide 24 text

Demo •  github.com/aschmidt75/serverspecplayground

Slide 25

Slide 25 text

Monitoring vs. Spec •  Dynamic Aspects (crashed servers, services not reachable, disk full, ...) •  Mostly in „internal form“, not human readable, special checks buried in scripts •  Static Aspects (how system is built) •  Explicit form, human readable •  Keep your system up & running •  Build according to a specification and prove compliance with it

Slide 26

Slide 26 text

Additional tools •  Comparable: rspec-system (! beaker-rspec), rspec-system-serverspec •  Integrate serverspec into vagrant as a provisioner: github.com/jvoorhis/vagrant-serverspec •  Reporting http://vincent.bernat.im/en/blog/2014-serverspec-test- infrastructure.html

Slide 27

Slide 27 text

Infrastructure QA

Slide 28

Slide 28 text

Infrastructure regression testing

Slide 29

Slide 29 text

Automated acceptance testing

Slide 30

Slide 30 text

Audit Capabilities

Slide 31

Slide 31 text

Work test driven – Define, build, compare your environments.

Slide 32

Slide 32 text

github.com/aschmidt75/serverspecplayground [email protected] xing.to/aschmidt @aschmidt75 ?

Slide 33

Slide 33 text

Cassini Consulting Niederlassung Düsseldorf Andreas Schmidt Bennigsen-Platz 1 40474 Düsseldorf Deutschland [email protected] visit www.cassini.de Alle Angaben basieren auf dem derzeitigen Kenntnisstand. Änderungen vorbehalten. Dieses Dokument von Cassini Consulting ist ausschließlich für den Adressaten bzw. Auftraggeber bestimmt. Es bleibt bis zur einer ausdrücklichen Übertragung von Nutzungsrechten Eigentum von Cassini. Jede Bearbeitung, Verwertung, Vervielfältigung und/oder gewerbsmäßige Verbreitung des Werkes ist nur mit Einverständnis von Cassini zulässig.