SlideShare a Scribd company logo
MONITOR-DRIVEN
INFRASTRUCTURE
DEVELOPMENT USING
ANSIBLE
Itamar Hassin
THE PREMISE
• Ansible scripts should be treated with the
same rigour with which we treat application
code
• In the way they’re tested
• In the way they’re written
JAMES WHITE MANIFESTO
•There is one system, not a collection of systems.
• The desired state of the system should be a known
quantity.
• The "known quantity" must be machine parseable.
• The actual state of the system must self-correct to the
desired state.
• The entire system must be deployable using source
media and text files.
• The only authoritative source for the actual state of the
system is the system.
UNTESTED CODE
WHY ANSIBLE?
•Assures scalability
•Repeatable and measurable
•Assures environments for consistent
development testing
Do not improve manual processes
if you can automate them instead.
•Fail fast (offline!) and cycle quickly
•Time To Rebuild System < Time To Fix It
THE REVOLUTION
Specify infrastructure configuration using
Ansible
You are writing
code!
INFRASTRUCTURE AS
CODE
•Employ TDD
•Version in SCM
•Part of the deliverable
•Submit to CI
•Have a story on the board
•Deploy to prod
XDD
• An activity whereby a feature is described
from its user’s perspective prior to its
implementation
SOFTWARE DELIVERY
User Story &
Acceptance
criteria
Code with unit
tests
Automated
tests
Specification Implementation Verification
UNIFIED DELIVERY
From this To this
BDD
Configuration
Instructions
Acceptance tests
(code)
•Instructions can be the acceptance tests
•Environments emerge in a running state
•Coded tests are living
documentation
MDD
• ServerSpec will serve as the testing
framework for the Anisible code
• Not in production if it’s not monitored
SERVERSPEC
describe service('sshd') do
it { should be_running }
end
describe service('ntpd') do
it { should be_running }
end
WHAT WE’RE GOING TO
DO
Controller
Watcher
TargetMonitor
Configure
{
WRITE A TEST
GET A TARGET
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.define "webserver"
config.vm.hostname = "webserver"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "33.33.33.33"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
ansible.inventory_path = "inventory.ini"
ansible.sudo = true
end
end
GET A TARGET
RUN THE TEST
GET APACHE PLAYBOOK
CONFIGURE TARGET
RUN THE TEST
CUCUMBER
Feature: App deploys to a VM
Background:
Given I have a vm with ip "33.33.33.33"
When I provision users on it
Scenario: Adding users
Then I can log on to it as the "deploy" user
And I can log on to it as the "root" user
Scenario: Adding Linux dependencies
When I run the "webserver" ansible playbook
And I log on as "deploy", there is no "ruby"
But "gcc" is present
CUCUMBER
IMPLEMENTATION
Then(/^I can log on to it as the "(.*?)" user$/) do |user|
result = system "ssh #{user}@#{@ip} exit"
result.should be_true
end
When(/^I run the "(.*?)" ansible playbook$/) do |playbook|
command = %W(../devops/#{playbook}.yml -i webhosts)
result = system 'ansible-playbook', *command
result.should be_true
end
WHY BOTHER?
• ServerSpec is to Ansible as rSpec is to Ruby
• You do not want your Ansible code to be
used untested
SOURCE CONTROL
SCaaCC
• Ansible code is part of the delivered code
• Developers and SysAdmins share code
using git for modifications.
• HugOps can use master
• Others can use branching or forking
SOURCE CONTROL
• Run ServerSpec prior to committing code
• Commit
• CI will take care of the rest
• Integration tests
• Environment Promotion
CI
Commit CI
ServerSpe
c
Cucumber VMTest
VMStaging
VMProd
XP PRACTICES
• SysAdmins are part of the development
team
• Participate in standups, part of a
story/task cards
• Participate in pairing sessions
• Empathise
devopsdays.org
REFERENCES
The Visible Ops Handbook
blog.websages.com/2010/12/10/jameswhite-manifesto/
rspec.info serverspec.comcukes.info
ansible.com galaxy.ansible.com
QUESTIONS & THANK YOU!
@itababy
www.in-context.com

More Related Content

PPTX
Ansible presentation
PDF
Testing Ansible with Jenkins and Docker
PDF
How Ansible Makes Automation Easy
PDF
Deploying PHP Applications with Ansible
PDF
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
PDF
Investigation of testing with ansible
PPTX
Ansible module development 101
PDF
Ansible Oxford - Cows & Containers
Ansible presentation
Testing Ansible with Jenkins and Docker
How Ansible Makes Automation Easy
Deploying PHP Applications with Ansible
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
Investigation of testing with ansible
Ansible module development 101
Ansible Oxford - Cows & Containers

What's hot (20)

PDF
infra-as-code
PDF
Ansible and AWS
PPTX
Go Faster with Ansible (PHP meetup)
PDF
Jenkins and ansible reference
PPTX
Go Faster with Ansible (AWS meetup)
PDF
Ansible Crash Course
PDF
CI/CD Using Ansible and Jenkins for Infrastructure
PDF
Ansible
PDF
Ansible Case Studies
PDF
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
PDF
A quick intro to Ansible
PDF
Ansible + WordPress
PPTX
Docker ansible-make-chef-puppet-unnecessary-minnihan
PPTX
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
PDF
Introduction to Ansible (Pycon7 2016)
PDF
Continuous Testing with Molecule, Ansible, and GitHub Actions
PPTX
Testing Ansible Infrastructure With Serverspec
PDF
Ansible Introduction
PDF
Ansible 2 and Ansible Galaxy 2
PDF
Ansible Intro - June 2015 / Ansible Barcelona User Group
infra-as-code
Ansible and AWS
Go Faster with Ansible (PHP meetup)
Jenkins and ansible reference
Go Faster with Ansible (AWS meetup)
Ansible Crash Course
CI/CD Using Ansible and Jenkins for Infrastructure
Ansible
Ansible Case Studies
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
A quick intro to Ansible
Ansible + WordPress
Docker ansible-make-chef-puppet-unnecessary-minnihan
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Introduction to Ansible (Pycon7 2016)
Continuous Testing with Molecule, Ansible, and GitHub Actions
Testing Ansible Infrastructure With Serverspec
Ansible Introduction
Ansible 2 and Ansible Galaxy 2
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ad

Similar to Monitor-Driven Development Using Ansible (20)

PDF
Infrastructure = Code
PPTX
Introduction to Ansible - Jan 28 - Austin MeetUp
PDF
UNM Tech Day 2018 - Ansible: 
Server and Network Device Automation
PDF
Automated Deployment and Configuration Engines. Ansible
PDF
Ansible - Hands on Training
PDF
Ansible Tutorial.pdf
PPTX
Ansible - Why and what
PDF
Talk about Ansible and Infrastructure as Code
PDF
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
PDF
Ansible not only for Dummies
PDF
DevOps(3) : Ansible - (MOSG)
PDF
DevOps for Humans - Ansible for Drupal Deployment Victory!
PDF
Automation with ansible
PPTX
SESSION Ansible how to deploy and push resources
PPTX
iac.pptx
PPTX
Infrastructure as Code for Network
PPTX
ansible : Infrastructure automation,idempotent and more
ODP
Infrastructure as a Code
PDF
Using Ansible for Deploying to Cloud Environments
PDF
Infrastructure as code
Infrastructure = Code
Introduction to Ansible - Jan 28 - Austin MeetUp
UNM Tech Day 2018 - Ansible: 
Server and Network Device Automation
Automated Deployment and Configuration Engines. Ansible
Ansible - Hands on Training
Ansible Tutorial.pdf
Ansible - Why and what
Talk about Ansible and Infrastructure as Code
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
Ansible not only for Dummies
DevOps(3) : Ansible - (MOSG)
DevOps for Humans - Ansible for Drupal Deployment Victory!
Automation with ansible
SESSION Ansible how to deploy and push resources
iac.pptx
Infrastructure as Code for Network
ansible : Infrastructure automation,idempotent and more
Infrastructure as a Code
Using Ansible for Deploying to Cloud Environments
Infrastructure as code
Ad

Recently uploaded (20)

PPTX
ai tools demonstartion for schools and inter college
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Digital Strategies for Manufacturing Companies
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPT
Introduction Database Management System for Course Database
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
top salesforce developer skills in 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
ai tools demonstartion for schools and inter college
VVF-Customer-Presentation2025-Ver1.9.pptx
PTS Company Brochure 2025 (1).pdf.......
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
ISO 45001 Occupational Health and Safety Management System
Digital Strategies for Manufacturing Companies
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Design an Analysis of Algorithms I-SECS-1021-03
Odoo POS Development Services by CandidRoot Solutions
Introduction Database Management System for Course Database
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
top salesforce developer skills in 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia

Monitor-Driven Development Using Ansible