Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing server infrastructure with #serverspec

Testing server infrastructure with #serverspec

Open Source Datacenter Conference osdc.de
04/09/2014

An Introduction to serverspec (www.serverspec.org)

Andreas Schmidt

April 10, 2014
Tweet

More Decks by Andreas Schmidt

Other Decks in Technology

Transcript

  1. Cassini Consulting @cassinigmbh •  IT & Management Consulting Andreas Schmidt

    •  From Dev to Ops •  Infrastructure & Deployment Automation w/ ruby
  2. „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
  3. 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?
  4. 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.“
  5. 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
  6. Development box CM code Staging Provision Test locally CM code

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

    specs box „state“ Test on server(s) server spec „Spec“ box
  8. 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
  9. 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
  10. 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
  11. $ 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
  12. Demo •  Serverspec Basics •  Overview of resource types • 

    Using abstractions and facts •  Introduce roles •  Environment-independent specs through properties
  13. 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
  14. 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
  15. 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.