SlideShare a Scribd company logo
1 #Dynatrace
with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure
DevOps Days
Berlin
2 #Dynatrace
Insert
image here
Technology Strategist at Dynatrace
martin.etmajer@dynatrace.com
@metmajer
Martin Etmajer
3 #Dynatrace
Why Continuous Delivery?
4 #Dynatrace
Why Continuous Delivery?
5 #Dynatrace
Utmost Goal: Minimize Cycle Time
feature cycle time time
Customer Users
6 #Dynatrace
Utmost Goal: Minimize Cycle Time
feature cycle time time
Customer minimize Users
7 #Dynatrace
Utmost Goal: Minimize Cycle Time
feature cycle time time
Customer
This is when you
create value!
minimize
8 #Dynatrace
Utmost Goal: Minimize Cycle Time
feature cycle time time
Customer
You
This is when you
create value!
minimize
9 #Dynatrace
Utmost Goal: Minimize Cycle Time
feature cycle time time
Customer
You
minimize
It’s about getting your features into your users’ hands
as quickly and confidently as possible!
10 #Dynatrace
Align Development and IT Operations
IT OPERATIONS
DEVELOPMENT
time
11 #Dynatrace
Align Development and IT Operations
IT OPERATIONS
DEVELOPMENT
current iteration
(e.g. 2-week time-box)
time
12 #Dynatrace
Align Development and IT Operations
IT OPERATIONS
DEVELOPMENT
current iteration
(e.g. 2-week time-box)
time
Planning
13 #Dynatrace
Align Development and IT Operations
IT OPERATIONS
DEVELOPMENT
current iteration
(e.g. 2-week time-box)
time
Planning
Implementing
and testing
14 #Dynatrace
Align Development and IT Operations
IT OPERATIONS
DEVELOPMENT
current iteration
(e.g. 2-week time-box)
time
Planning
Implementing
and testing
Working and
deployable code
15 #Dynatrace
Test-Driven Infrastructure
16 #Dynatrace
You write code!
17 #Dynatrace
“Make it work. Make it right. Make it fast.”
Kent Beck, Creator of Extreme Programming and Test-Driven Development
Get the code to
operate correctly
Make the code clear,
enforce good design Optimize
18 #Dynatrace
The Red, Green, Refactor Cycle of TDD
Write a Failing Test
Make the Test PassClean Up your Code
Small increments
Able to return to known working code
Designed and
tested code
Protects against regressions
19 #Dynatrace
» Refactoring
» simplify
» modularize (use 3rd-party Ansible roles)
» Migrating to different Platforms
» OS
» Cloud Providers
» Migrating to different Automation Tool
» Ansible, Chef, Puppet
» Bash, Perl, etc.
Why you shouldn’t rely on a single tool?
20 #Dynatrace
» Refactoring
» simplify
» modularize (use 3rd-party Ansible roles)
» Migrating to different Platforms
» OS
» Cloud Providers
» Migrating to different Automation Tool
» Ansible, Chef, Puppet
» Bash, Perl, etc.
Why you shouldn’t rely on a single tool?
With TDD you express your intentions twice:
once in the code and once in the test.
If they don’t match, tests fail and you’ve caught a bug!
21 #Dynatrace
Test Kitchen
Key Concepts
Pluggable Architecture
22 #Dynatrace
» Drivers
» Platforms
» Provisioners
» Test Suites
Key Concepts
23 #Dynatrace
» Drivers
» Platforms
» Provisioners
» Test Suites
Key Concepts
24 #Dynatrace
Drivers let you run your code on various...
Cloud Providers
» Azure, Cloud Stack, EC2, Digital Ocean, GCE, Rackspace,...
Virtualization Technologies
» Vagrant, Docker, LXC
Test Kitchen: Drivers
25 #Dynatrace
» Drivers
» Platforms
» Provisioners
» Test Suites
Key Concepts
26 #Dynatrace
Platforms are the Operating Systems you want to run on.
Platforms
» Linux- or Windows-based (since Test Kitchen 1.4.0)
How to manage dependencies?
» Automatically resolved when using Docker or Vagrant
» Build your own and link them in the configuration file
Test Kitchen: Platforms
27 #Dynatrace
» Drivers
» Platforms
» Provisioners
» Test Suites
Key Concepts
28 #Dynatrace
Provisioners are the tools used to converge the environment.
Provisioners
» Ansible, Chef, CFEngine, Puppet, SaltStack
Why cool?
» Useful if you need to support multiple of these tools
Test Kitchen: Provisioners
29 #Dynatrace
» Drivers
» Platforms
» Provisioners
» Test Suites
Key Concepts
30 #Dynatrace
Test Suites define the tests to run against each platform.
Test Frameworks
» Bash, Bats, Cucumber, RSpec, Serverspec
Test Kitchen: Test Suites
31 #Dynatrace
Test Kitchen
Installation
32 #Dynatrace
Installation
Ready?
$ gem install test-kitchen kitchen-docker kitchen-ansible
Test Kitchen: Installation
$ kitchen version
Test Kitchen version 1.4.2
33 #Dynatrace
Test Kitchen
Configuration
34 #Dynatrace
Create an Ansible Role
Initialize Test Kitchen
$ mkdir –p ansible/roles/my-role
$ cd ansible/roles/my-role
Test Kitchen: Testing an Ansible Role
$ kitchen init --driver=docker --provisioner=ansible_playbook
create .kitchen.yml
create test/integration/default
Configuration goes here!
Tests go here!
35 #Dynatrace
.kitchen.yml (as provided via `kitchen init`)
---
driver:
name: docker
provisioner:
name: ansible_playbook
platforms:
- name: ubuntu-14.04
- name: centos-7.1
suites:
- name: default
run_list:
attributes:
Test Kitchen: Testing an Ansible Role
Names resolve to
Docker Images on
the Docker Hub
36 #Dynatrace
.kitchen.yml (slightly adjusted)
---
driver:
name: docker
provisioner:
name: ansible_playbook
hosts: test-kitchen
ansible_verbose: false
ansible_verbosity: 2
Test Kitchen: Testing an Ansible Role
platforms:
- name: ubuntu-14.04
- name: centos-7.1
suites:
- name: default
37 #Dynatrace
$ kitchen list
Instance Driver Provisioner Transport Last Action
default-ubuntu-1404 Docker AnsiblePlaybook Ssh <Not Created>
default-centos-71 Docker AnsiblePlaybook Ssh <Not Created>
`kitchen list`: List Test Kitchen Instances
Test Kitchen: Installation
This will change...Test Suite Platform
38 #Dynatrace
Test Kitchen
Write an Integration Test
39 #Dynatrace
Create an Ansible Playbook for Test Suite ‘default’
Test Kitchen: Testing an Ansible Role
$ kitchen init --driver=docker --provisioner=ansible_playbook
create .kitchen.yml
create test/integration/default
Configuration goes here!
Tests go here!
40 #Dynatrace
test/integration/default/default.yml
---
- hosts: test-kitchen
pre_tasks:
...
roles:
- my-role
post_tasks:
...
Test Kitchen: Testing an Ansible Role
Create your
environment
Ansible Playbook
Test Suite
41 #Dynatrace
Serverspec and RSpec
A Short Primer
42 #Dynatrace
RSpec is a TDD tool for Ruby programmers.
RSpec
require ‘foo’
describe Foo do
before do
@foo = Foo.new
end
it ‘method #bar does something useful’ do
@foo.bar.should eq ‘something useful’
end
end
43 #Dynatrace
Serverspec is RSpec for your infrastructure.
Serverspec
require ‘serverspec’
describe user(‘foo’) do
it { should exist }
it { should belong_to_group ‘foo’ }
end
describe file(‘/opt/bar’) do
it { should be_directory }
it { should be_mode 777 }
it { should be_owned_by ‘foo’ }
it { should be_grouped_into ‘foo’ }
end
describe service(‘bar’) do
it { should be_enabled }
it { should be_running }
end
describe port(8080) do
it { should be_listening }
end
describe command(‘apachectl –M’) do
its(:stdout) { should contain(‘proxy_module’) }
end
Resource
Matcher
44 #Dynatrace
test/integration/default/serverspec/default_spec.rb
require ‘serverspec’
describe user(‘foo’) do
it { should exist }
it { should belong_to_group ‘foo’ }
end
Test Kitchen: Testing an Ansible Role
Test
Test Suite Do Serverspec!
45 #Dynatrace
`kitchen test`: Run Test Kitchen Tests
Test Kitchen: Testing an Ansible Role
$ kitchen test default-ubuntu-1404
$ kitchen test ubuntu
$ kitchen test
regex!
$ kitchen list
Instance Driver Provisioner Transport Last Action
default-ubuntu-1404 Docker AnsiblePlaybook Ssh <Not Created>
default-centos-71 Docker AnsiblePlaybook Ssh <Not Created>
46 #Dynatrace
Test Kitchen: Stages
test = converge verify destroy
Instance created and provisioned
Instance tested and verified
47 #Dynatrace
`kitchen verify`: Run Test Kitchen Tests
$ kitchen verify ubuntu
...
User "foo"
should exist
should belong to group "foo"
Finished in 0.14825 seconds (files took 0.6271 seconds to load)
2 examples, 0 failures
Finished verifying <default-ubuntu-1404> (0m37.21s).
Test Kitchen: Testing an Ansible Role
48 #Dynatrace
`kitchen list`: List Test Kitchen Instances
Test Kitchen: Testing an Ansible Role
$ kitchen list
Instance Driver Provisioner Transport Last Action
default-ubuntu-1404 Docker AnsiblePlaybook Ssh Verified
default-centos-71 Docker AnsiblePlaybook Ssh <Not Created>
49 #Dynatrace
Test Kitchen with Ansible
Advanced Tips
50 #Dynatrace
Resolving Role Requirements
51 #Dynatrace
.kitchen.yml
---
driver:
name: docker
provisioner:
name: ansible_playbook
hosts: test-kitchen
requirements_path: requirements.yml
ansible_verbose: false
ansible_verbosity: 2
Test Kitchen: Resolve Role Requirements
platforms:
- name: ubuntu-14.04
- name: centos-7.1
suites:
- name: default
Declare required roles
on Ansible Galaxy, GitHub,
or Git, Mercurial, etc. repos
52 #Dynatrace
Testing Ansible Roles
in Amazon EC2
53 #Dynatrace
.kitchen.yml
---
driver:
name: ec2
aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID']%>"
aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY']%>"
aws_ssh_key_id: "<%= ENV['AWS_SSH_KEY_ID']%>"
region: eu-west-1
availability_zone: eu-west-1b
transport:
ssh_key: "<%= ENV['AWS_SSH_KEY_PATH']%>"
username: admin
...
Test Kitchen: Testing Ansible Roles in EC2
Environment Variables
54 #Dynatrace
Testing REST APIs
with RSpec
Not supported by Serverspec
55 #Dynatrace
test/integration/default/serverspec/default_spec.rb
require ‘json’
require ‘net/http’
...
describe ‘Server REST API’ do
it ‘/rest/foo responds correctly’ do
uri = URI(‘http://localhost:8080/rest/foo’)
request = Net::HTTP::Get.new(uri, { ‘Accept’ => ‘application/json’ })
request.basic_auth(‘foo’, ‘foo’)
response = Net::HTTP.new(uri.host, uri.port).request(request)
expect(response.code).to eq 200
expect(JSON.parse(response.body)).to eq { ‘bar’ => ‘baz’ }
end
end
Test Kitchen: Testing REST APIs
56 #Dynatrace
Dynatrace-Ansible Project
Further Examples: https://github.com/dynaTrace/Dynatrace-Ansible
57 #Dynatrace
58 #Dynatrace
Demo Time!
59 #Dynatrace
Questions?
60 #Dynatrace

More Related Content

What's hot

CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Edureka!
 
Ansible
AnsibleAnsible
Ansible
Vishal Yadav
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
Mehmet Ali Aydın
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
Dennis Rowe
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Suresh Kumar
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
Yashar Esmaildokht
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
Amazon Web Services
 
DevOps 101 - an Introduction to DevOps
DevOps 101  - an Introduction to DevOpsDevOps 101  - an Introduction to DevOps
DevOps 101 - an Introduction to DevOps
Red Gate Software
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
CoreStack
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
DevSecOps
DevSecOpsDevSecOps
DevSecOps
Cheah Eng Soon
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
Anas
 
Introduction to DevSecOps
Introduction to DevSecOpsIntroduction to DevSecOps
Introduction to DevSecOps
abhimanyubhogwan
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
Kasper Nissen
 
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
Jo Hoon
 
Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containers
Amazon Web Services
 
DevOps Implementation Roadmap
DevOps Implementation RoadmapDevOps Implementation Roadmap
DevOps Implementation Roadmap
SofiaCarter4
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
Amazon Web Services
 

What's hot (20)

CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
Ansible
AnsibleAnsible
Ansible
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
DevOps 101 - an Introduction to DevOps
DevOps 101  - an Introduction to DevOpsDevOps 101  - an Introduction to DevOps
DevOps 101 - an Introduction to DevOps
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 
DevSecOps
DevSecOpsDevSecOps
DevSecOps
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Introduction to DevSecOps
Introduction to DevSecOpsIntroduction to DevSecOps
Introduction to DevSecOps
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
 
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
 
Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containers
 
DevOps Implementation Roadmap
DevOps Implementation RoadmapDevOps Implementation Roadmap
DevOps Implementation Roadmap
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
 

Similar to Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec

Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
Martin Etmajer
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
Martin Etmajer
 
Stop Being Lazy and Test Your Software
Stop Being Lazy and Test Your SoftwareStop Being Lazy and Test Your Software
Stop Being Lazy and Test Your Software
Laura Frank Tacho
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineers
Docker, Inc.
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
NigussMehari4
 
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
DockerCon EU 2015: Stop Being Lazy and Test Your Software!DockerCon EU 2015: Stop Being Lazy and Test Your Software!
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Docker, Inc.
 
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
PROIDEA
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
Yaniv cohen
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
Kevin Harvey
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Amazon Web Services
 
Introduction to Automated Deployments with Ansible
Introduction to Automated Deployments with AnsibleIntroduction to Automated Deployments with Ansible
Introduction to Automated Deployments with Ansible
Martin Etmajer
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
Automate Thyself
Automate ThyselfAutomate Thyself
Automate Thyself
Ortus Solutions, Corp
 
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
Satish Devarapalli
 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Edmund Dipple
 
Test Kitchen and Infrastructure as Code
Test Kitchen and Infrastructure as CodeTest Kitchen and Infrastructure as Code
Test Kitchen and Infrastructure as Code
Cybera Inc.
 
Dev ops meetup
Dev ops meetupDev ops meetup
Dev ops meetup
Bigdata Meetup Kochi
 
CI and CD
CI and CDCI and CD

Similar to Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec (20)

Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Puppet, Test Kitchen, Serverspec and RSpec
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
 
Stop Being Lazy and Test Your Software
Stop Being Lazy and Test Your SoftwareStop Being Lazy and Test Your Software
Stop Being Lazy and Test Your Software
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineers
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
DockerCon EU 2015: Stop Being Lazy and Test Your Software!DockerCon EU 2015: Stop Being Lazy and Test Your Software!
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
 
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
Atmosphere 2018: Yury Tsarev - TEST DRIVEN INFRASTRUCTURE FOR HIGHLY PERFORMI...
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
Introduction to Automated Deployments with Ansible
Introduction to Automated Deployments with AnsibleIntroduction to Automated Deployments with Ansible
Introduction to Automated Deployments with Ansible
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
Automate Thyself
Automate ThyselfAutomate Thyself
Automate Thyself
 
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
Deploying Microservices - Makefiles, K8S Config Templates, Git Submodules, He...
 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
 
Test Kitchen and Infrastructure as Code
Test Kitchen and Infrastructure as CodeTest Kitchen and Infrastructure as Code
Test Kitchen and Infrastructure as Code
 
Dev ops meetup
Dev ops meetupDev ops meetup
Dev ops meetup
 
CI and CD
CI and CDCI and CD
CI and CD
 

More from Martin Etmajer

Continuous Delivery 101
Continuous Delivery 101Continuous Delivery 101
Continuous Delivery 101
Martin Etmajer
 
User Story Mapping 101
User Story Mapping 101User Story Mapping 101
User Story Mapping 101
Martin Etmajer
 
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
Martin Etmajer
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer
 
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
Martin Etmajer
 
(R)Evolutionize APM - APM in Continuous Delivery and DevOps
(R)Evolutionize APM - APM in Continuous Delivery and DevOps(R)Evolutionize APM - APM in Continuous Delivery and DevOps
(R)Evolutionize APM - APM in Continuous Delivery and DevOps
Martin Etmajer
 
Deploying On-Prem as SaaS: Why we go with Ansible
Deploying On-Prem as SaaS: Why we go with AnsibleDeploying On-Prem as SaaS: Why we go with Ansible
Deploying On-Prem as SaaS: Why we go with Ansible
Martin Etmajer
 
Automated Deployments
Automated DeploymentsAutomated Deployments
Automated Deployments
Martin Etmajer
 

More from Martin Etmajer (8)

Continuous Delivery 101
Continuous Delivery 101Continuous Delivery 101
Continuous Delivery 101
 
User Story Mapping 101
User Story Mapping 101User Story Mapping 101
User Story Mapping 101
 
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
Challenges in a Microservices Age: Monitoring, Logging and Tracing on Red Hat...
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
Monitoring Microservices at Scale on OpenShift (OpenShift Commons Briefing #52)
 
(R)Evolutionize APM - APM in Continuous Delivery and DevOps
(R)Evolutionize APM - APM in Continuous Delivery and DevOps(R)Evolutionize APM - APM in Continuous Delivery and DevOps
(R)Evolutionize APM - APM in Continuous Delivery and DevOps
 
Deploying On-Prem as SaaS: Why we go with Ansible
Deploying On-Prem as SaaS: Why we go with AnsibleDeploying On-Prem as SaaS: Why we go with Ansible
Deploying On-Prem as SaaS: Why we go with Ansible
 
Automated Deployments
Automated DeploymentsAutomated Deployments
Automated Deployments
 

Recently uploaded

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 

Recently uploaded (20)

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 

Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec

  • 1. 1 #Dynatrace with Ansible, Test Kitchen, Serverspec and RSpec Test-Driven Infrastructure DevOps Days Berlin
  • 2. 2 #Dynatrace Insert image here Technology Strategist at Dynatrace martin.etmajer@dynatrace.com @metmajer Martin Etmajer
  • 5. 5 #Dynatrace Utmost Goal: Minimize Cycle Time feature cycle time time Customer Users
  • 6. 6 #Dynatrace Utmost Goal: Minimize Cycle Time feature cycle time time Customer minimize Users
  • 7. 7 #Dynatrace Utmost Goal: Minimize Cycle Time feature cycle time time Customer This is when you create value! minimize
  • 8. 8 #Dynatrace Utmost Goal: Minimize Cycle Time feature cycle time time Customer You This is when you create value! minimize
  • 9. 9 #Dynatrace Utmost Goal: Minimize Cycle Time feature cycle time time Customer You minimize It’s about getting your features into your users’ hands as quickly and confidently as possible!
  • 10. 10 #Dynatrace Align Development and IT Operations IT OPERATIONS DEVELOPMENT time
  • 11. 11 #Dynatrace Align Development and IT Operations IT OPERATIONS DEVELOPMENT current iteration (e.g. 2-week time-box) time
  • 12. 12 #Dynatrace Align Development and IT Operations IT OPERATIONS DEVELOPMENT current iteration (e.g. 2-week time-box) time Planning
  • 13. 13 #Dynatrace Align Development and IT Operations IT OPERATIONS DEVELOPMENT current iteration (e.g. 2-week time-box) time Planning Implementing and testing
  • 14. 14 #Dynatrace Align Development and IT Operations IT OPERATIONS DEVELOPMENT current iteration (e.g. 2-week time-box) time Planning Implementing and testing Working and deployable code
  • 17. 17 #Dynatrace “Make it work. Make it right. Make it fast.” Kent Beck, Creator of Extreme Programming and Test-Driven Development Get the code to operate correctly Make the code clear, enforce good design Optimize
  • 18. 18 #Dynatrace The Red, Green, Refactor Cycle of TDD Write a Failing Test Make the Test PassClean Up your Code Small increments Able to return to known working code Designed and tested code Protects against regressions
  • 19. 19 #Dynatrace » Refactoring » simplify » modularize (use 3rd-party Ansible roles) » Migrating to different Platforms » OS » Cloud Providers » Migrating to different Automation Tool » Ansible, Chef, Puppet » Bash, Perl, etc. Why you shouldn’t rely on a single tool?
  • 20. 20 #Dynatrace » Refactoring » simplify » modularize (use 3rd-party Ansible roles) » Migrating to different Platforms » OS » Cloud Providers » Migrating to different Automation Tool » Ansible, Chef, Puppet » Bash, Perl, etc. Why you shouldn’t rely on a single tool? With TDD you express your intentions twice: once in the code and once in the test. If they don’t match, tests fail and you’ve caught a bug!
  • 21. 21 #Dynatrace Test Kitchen Key Concepts Pluggable Architecture
  • 22. 22 #Dynatrace » Drivers » Platforms » Provisioners » Test Suites Key Concepts
  • 23. 23 #Dynatrace » Drivers » Platforms » Provisioners » Test Suites Key Concepts
  • 24. 24 #Dynatrace Drivers let you run your code on various... Cloud Providers » Azure, Cloud Stack, EC2, Digital Ocean, GCE, Rackspace,... Virtualization Technologies » Vagrant, Docker, LXC Test Kitchen: Drivers
  • 25. 25 #Dynatrace » Drivers » Platforms » Provisioners » Test Suites Key Concepts
  • 26. 26 #Dynatrace Platforms are the Operating Systems you want to run on. Platforms » Linux- or Windows-based (since Test Kitchen 1.4.0) How to manage dependencies? » Automatically resolved when using Docker or Vagrant » Build your own and link them in the configuration file Test Kitchen: Platforms
  • 27. 27 #Dynatrace » Drivers » Platforms » Provisioners » Test Suites Key Concepts
  • 28. 28 #Dynatrace Provisioners are the tools used to converge the environment. Provisioners » Ansible, Chef, CFEngine, Puppet, SaltStack Why cool? » Useful if you need to support multiple of these tools Test Kitchen: Provisioners
  • 29. 29 #Dynatrace » Drivers » Platforms » Provisioners » Test Suites Key Concepts
  • 30. 30 #Dynatrace Test Suites define the tests to run against each platform. Test Frameworks » Bash, Bats, Cucumber, RSpec, Serverspec Test Kitchen: Test Suites
  • 32. 32 #Dynatrace Installation Ready? $ gem install test-kitchen kitchen-docker kitchen-ansible Test Kitchen: Installation $ kitchen version Test Kitchen version 1.4.2
  • 34. 34 #Dynatrace Create an Ansible Role Initialize Test Kitchen $ mkdir –p ansible/roles/my-role $ cd ansible/roles/my-role Test Kitchen: Testing an Ansible Role $ kitchen init --driver=docker --provisioner=ansible_playbook create .kitchen.yml create test/integration/default Configuration goes here! Tests go here!
  • 35. 35 #Dynatrace .kitchen.yml (as provided via `kitchen init`) --- driver: name: docker provisioner: name: ansible_playbook platforms: - name: ubuntu-14.04 - name: centos-7.1 suites: - name: default run_list: attributes: Test Kitchen: Testing an Ansible Role Names resolve to Docker Images on the Docker Hub
  • 36. 36 #Dynatrace .kitchen.yml (slightly adjusted) --- driver: name: docker provisioner: name: ansible_playbook hosts: test-kitchen ansible_verbose: false ansible_verbosity: 2 Test Kitchen: Testing an Ansible Role platforms: - name: ubuntu-14.04 - name: centos-7.1 suites: - name: default
  • 37. 37 #Dynatrace $ kitchen list Instance Driver Provisioner Transport Last Action default-ubuntu-1404 Docker AnsiblePlaybook Ssh <Not Created> default-centos-71 Docker AnsiblePlaybook Ssh <Not Created> `kitchen list`: List Test Kitchen Instances Test Kitchen: Installation This will change...Test Suite Platform
  • 38. 38 #Dynatrace Test Kitchen Write an Integration Test
  • 39. 39 #Dynatrace Create an Ansible Playbook for Test Suite ‘default’ Test Kitchen: Testing an Ansible Role $ kitchen init --driver=docker --provisioner=ansible_playbook create .kitchen.yml create test/integration/default Configuration goes here! Tests go here!
  • 40. 40 #Dynatrace test/integration/default/default.yml --- - hosts: test-kitchen pre_tasks: ... roles: - my-role post_tasks: ... Test Kitchen: Testing an Ansible Role Create your environment Ansible Playbook Test Suite
  • 41. 41 #Dynatrace Serverspec and RSpec A Short Primer
  • 42. 42 #Dynatrace RSpec is a TDD tool for Ruby programmers. RSpec require ‘foo’ describe Foo do before do @foo = Foo.new end it ‘method #bar does something useful’ do @foo.bar.should eq ‘something useful’ end end
  • 43. 43 #Dynatrace Serverspec is RSpec for your infrastructure. Serverspec require ‘serverspec’ describe user(‘foo’) do it { should exist } it { should belong_to_group ‘foo’ } end describe file(‘/opt/bar’) do it { should be_directory } it { should be_mode 777 } it { should be_owned_by ‘foo’ } it { should be_grouped_into ‘foo’ } end describe service(‘bar’) do it { should be_enabled } it { should be_running } end describe port(8080) do it { should be_listening } end describe command(‘apachectl –M’) do its(:stdout) { should contain(‘proxy_module’) } end Resource Matcher
  • 44. 44 #Dynatrace test/integration/default/serverspec/default_spec.rb require ‘serverspec’ describe user(‘foo’) do it { should exist } it { should belong_to_group ‘foo’ } end Test Kitchen: Testing an Ansible Role Test Test Suite Do Serverspec!
  • 45. 45 #Dynatrace `kitchen test`: Run Test Kitchen Tests Test Kitchen: Testing an Ansible Role $ kitchen test default-ubuntu-1404 $ kitchen test ubuntu $ kitchen test regex! $ kitchen list Instance Driver Provisioner Transport Last Action default-ubuntu-1404 Docker AnsiblePlaybook Ssh <Not Created> default-centos-71 Docker AnsiblePlaybook Ssh <Not Created>
  • 46. 46 #Dynatrace Test Kitchen: Stages test = converge verify destroy Instance created and provisioned Instance tested and verified
  • 47. 47 #Dynatrace `kitchen verify`: Run Test Kitchen Tests $ kitchen verify ubuntu ... User "foo" should exist should belong to group "foo" Finished in 0.14825 seconds (files took 0.6271 seconds to load) 2 examples, 0 failures Finished verifying <default-ubuntu-1404> (0m37.21s). Test Kitchen: Testing an Ansible Role
  • 48. 48 #Dynatrace `kitchen list`: List Test Kitchen Instances Test Kitchen: Testing an Ansible Role $ kitchen list Instance Driver Provisioner Transport Last Action default-ubuntu-1404 Docker AnsiblePlaybook Ssh Verified default-centos-71 Docker AnsiblePlaybook Ssh <Not Created>
  • 49. 49 #Dynatrace Test Kitchen with Ansible Advanced Tips
  • 51. 51 #Dynatrace .kitchen.yml --- driver: name: docker provisioner: name: ansible_playbook hosts: test-kitchen requirements_path: requirements.yml ansible_verbose: false ansible_verbosity: 2 Test Kitchen: Resolve Role Requirements platforms: - name: ubuntu-14.04 - name: centos-7.1 suites: - name: default Declare required roles on Ansible Galaxy, GitHub, or Git, Mercurial, etc. repos
  • 52. 52 #Dynatrace Testing Ansible Roles in Amazon EC2
  • 53. 53 #Dynatrace .kitchen.yml --- driver: name: ec2 aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID']%>" aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY']%>" aws_ssh_key_id: "<%= ENV['AWS_SSH_KEY_ID']%>" region: eu-west-1 availability_zone: eu-west-1b transport: ssh_key: "<%= ENV['AWS_SSH_KEY_PATH']%>" username: admin ... Test Kitchen: Testing Ansible Roles in EC2 Environment Variables
  • 54. 54 #Dynatrace Testing REST APIs with RSpec Not supported by Serverspec
  • 55. 55 #Dynatrace test/integration/default/serverspec/default_spec.rb require ‘json’ require ‘net/http’ ... describe ‘Server REST API’ do it ‘/rest/foo responds correctly’ do uri = URI(‘http://localhost:8080/rest/foo’) request = Net::HTTP::Get.new(uri, { ‘Accept’ => ‘application/json’ }) request.basic_auth(‘foo’, ‘foo’) response = Net::HTTP.new(uri.host, uri.port).request(request) expect(response.code).to eq 200 expect(JSON.parse(response.body)).to eq { ‘bar’ => ‘baz’ } end end Test Kitchen: Testing REST APIs
  • 56. 56 #Dynatrace Dynatrace-Ansible Project Further Examples: https://github.com/dynaTrace/Dynatrace-Ansible

Editor's Notes

  1. And as we are dealing with code - “infrastructure as code” namely – why shouldn’t we apply the same principles that help us create better software to create better infrastructure? After all, a bug in the environment may have more severe consequences than a bug in a software.
  2. See: - http://c2.com/cgi/wiki?MakeItWorkMakeItRightMakeItFast
  3. See: http://www.jamesshore.com/Agile-Book/test_driven_development.html http://blog.goyello.com/2011/09/13/red-green-refactor-cycle/