2. www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
DevOpsGuys accelerate & transform the
way organisations deliversoftware
3. 3
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
The plan…
• The history of Automated Testing for Infrastructure
• What is Test Driven Development?
• Test Kitchen
• Ansible
• The result…
6. 6
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
Hudson, Puppet, Cucumbers and Tramps
● Julian Simpson & Patrick Debois circa 2010 @ UKUUG
– Hudson hit my Puppet with a Cucumber - http://bit.ly/1YaGvDw
● Cucumber-libvirt
– https://github.com/proffalken/cucumber-libvirt/
● Vagrant
– https://vagrantup.com
7. 7
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
...but there must be a better way...
● Configuration Management is improving by 2012
– Puppet
– Chef
– CFEngine 3
● Tests are added retrospectively to manifests/recipes/promises
● Basic bash scripts or Nagios checks are still the norm
10. 10
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
Write your tests first
● Code to your acceptance criteria
● Test for what shouldn't be there, not just what you're adding
● If using Cucumber, educate the business to write your stories in
Gherkin Syntax (Given/When/Then)
● DON'T WRITE YOUR OWN TEST FRAMEWORK! USE SOMEONE
ELSES!!!
11. 11
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
What can you use?
● ServerSpec
– Ruby
– Rspec-based
– The “Unit Tests”
● Cucumber Nagios
– Ruby
– Cucumber-based
– Given/When/Then
– The “Functional Tests”
● Nagios
– What ever language you want
– Exit code dictates test result
● 0 – Works
● 1 – Warning
● 2 – Failed
● 3 – Unknown
– Tests move with you into production
monitoring
– The “Integration Tests”
13. 13
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
What is it?
● A test runner…
– YAML-based configuration
– Ruby (again!)
– Comes from Chef
– Works with Puppet and Ansible!
● Web: kitchen.ci
14. 14
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
How do I use it?
● Create a .kitchen.yml in your role's top level directory
● Run kitchen test
● Wait for the results
16. 16
www.devopsguys.com
Phone: 0800 368 7378 | e-mail: team@devopsguys.com
Ansible Concepts
● Tasks
– Take action “x” against server “y”
● Roles
– Collection of related tasks
● Plays
– A collection of roles that can create a
complete server/cluster
Welcome & short intro to me
<number>
About DOG
Hopefully time for a demo at the end!
Devs have had testing for years, SysAdmins have been a lot slower on the uptake but we are learning!
Why should we test? (NEXT SLIDE!!!!)
Previously – build by hand, install, don't bother checking it
Then – Build by script - “The script works”, right? Don't bother checking it
Next - “Works on my machine”, run the script, don't bother checking prod
The movement starts - “all the devs are doing it, so why can't we?”
Eventually – Monitoring works, it's good to go...
“Dev is similar to stage, stage is similar to prod, therefore what works in dev will work in prod”… WRONG!!!So what is the answer?