SlideShare a Scribd company logo
1 of 28
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Testing for Infrastructure as Code
A Beginner's Pattern
Presented by: Mike Caspar
Incremental Infrastructure
Coach
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
The Audience?
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Caspar Computer Services Inc.
-- Innovative Solutions since 1984 -
-
Caspar.NET
(5 cities in Canada / 10
years)
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Why am I here?
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
How do we start?
Very basic understanding of Ansible Inventory &
Groups
A sample environment
A starting pattern (The Test/Maintain Loop)
Moving machines between environments
Integrating Testing into the process (TDD for
Infrastructure)
Q & A
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Physical Servers Virtual Servers
Ansible works with both.
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Applications…
Not servers.
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Physical and Virtual Infrastructure
Production
Development
Staging (sort of)
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Inventory - Folders by Application Name
WALDO and GROVER are Application names…
Why is this important ?
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Inventory - Host Location and Types
City
Env.
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Application - Group Variables
---
# Playbook: GROVER_maintain_proxy.yml
# This playbook Maintains the GROVER Application
- name: ensure hosts are setup correctly on proxy servers in yyz
hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod
remote_user: root
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Tests can be attached and versioned along
with a specific version of Infrastructure
(think... testing & rollbacks)
Source Control….
Why ?
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Host Names not IP Addresses !
(virtual machines)
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
group_vars matching basics
Playbook hosts + Inventory + group_vars + --limit
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
group_vars matching basics
Playbook hosts + Inventory + group_vars + --limit
- name: ensure hosts are setup correctly on proxy servers in yyz
hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod
remote_user: root
Playbook
Inventory
group_vars
[GROVER_yyz_proxy_prod]
yyzproxy1.caspar.com
[GROVER_yyz_webservers_prod]
web1.caspar.com
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
The Test/Maintain Loop
_test
(govern)
_maintain
(dev)
_setup
(injected once)
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
The continual loop
( Dev/Test Continuous Loop)
APP_Maintain_serverType.yml
APP_Test_serverType.yml
APP_Maintain_serverType.yml
APP_Test_serverType.yml
The Test/Maintain Loop
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Adding a new Application (in dev/staging first)
APP_maintain_serverType.yml
APP_test_serverType.yml
APP_setup_serverType.yml (injected into loop only once).
APP_test_serverType.yml
The Test/Maintain Loop
( _setup injected only once )
_test
(govern)
_maintain
(dev)
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
---
# Playbook: GROVER_maintain_proxy.yml
# This playbook Maintains the GROVER Application
- name: ensure hosts are setup correctly on proxy servers in yyz
hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod
remote_user: root
roles:
- { role: GROVER-common }
- { role: GROVER-users }
- { role: GROBER-firewalls } tags: ['security'] }
- { role: COMMON-newrelic, state: present, tags: ['monitoring'] }
- { role: COMMON_puppet_agent, state: absent }
- name: ensure hosts are setup correctly on proxy servers in yul
hosts: GROVER_yul_proxy_staging, GROVER_yul_proxy_dev, GROVER_yul_proxy_prod
remote_user: root
roles:
- { role: GROVER-common }
- { role: GROVER-users }
- { role: GROBER-firewalls } tags: ['security'] }
- { role: COMMON-newrelic, state: present, tags: ['monitoring'] }
- { role: COMMON_puppet_agent, state: absent }
Notice the Application Name
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
We decide when a machine is in Dev/Staging/Production
(not physical location)
Production
Development
Staging (sort of)
To move a machine from Staging to Production….
Move it to another Inventory and run APP_maintain_
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_test_proxy.yml
ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_test_proxy.yml
ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_test_proxy.yml
ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_test_proxy.yml --limit a.host.com
ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_test_proxy.yml --limit a.host.com
ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_test_proxy.yml --limit a.host.com
ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_maintain_proxy.yml
ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_maintain_proxy.yml
ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_maintain_proxy.yml
Example commands
White - Dev
Blue - QA/Test
Orange - Governance/Ops
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Be careful of role
defaults
Empty Strings
Length of group_vars tag
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Why test_ instead of --check?
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
TDD - Test Driven Development
(learned from the Software Community)
THINK !
Write a Failing Test
Refactor
Make it Pass
http://www.extremeprogramming.org/rules/testfirst.html
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Why is this a useful way to start?
● New apps are not re-deployed, the machines simply move inventory location
● tests have already run many times
● Testing and Governance work can be done in parallel to development tasks
● Development teams know right away if they broke something before and/or after !
● Ability to use TDD software concepts for hardware
● Infrastructure can contain a version with matching tests
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
T.D.D. concepts for Infrastructure
To truly do Incremental Infrastructure delivery, we must
have an automated way to know that we haven’t broken
something else in the system when we make changes.
The key is finding a method to allow constant evolution of
our code base (infrastructure).
We do not need to reinvent an approach. Test Driven
Development concepts have proven effective in
incremental software delivery and can be re-used
effectively for infrastructure as code..
Mike Caspar, 2016
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Git Repository for Sample Project
Sample project file(s) available here…
https://github.com/MikeCaspar/ansibleFest2016SFO
Mike Caspar, 2016
© Mike Caspar, 2016
Testing for Infrastructure as Code by Mike Caspar
is licenced under an Attribution-ShareAlike 4.0 International licence
Mike Caspar
Incremental Infrastructure Coach
Enterprise agile Coach
email: mike@caspar.com
twitter: @mikecaspar
blog: http://mike-
caspar.blogspot.com

More Related Content

Viewers also liked

How to increase traffic to your WordPress website.
How to increase traffic to your WordPress website. How to increase traffic to your WordPress website.
How to increase traffic to your WordPress website. Liquis Design
 
Guia De Estudio Digestivo
Guia De Estudio DigestivoGuia De Estudio Digestivo
Guia De Estudio DigestivoLuciana Yohai
 
The State of Facilities at Eastern Region Institutions JUNE16
The State of Facilities at Eastern Region Institutions JUNE16The State of Facilities at Eastern Region Institutions JUNE16
The State of Facilities at Eastern Region Institutions JUNE16Sightlines
 
Charitable Giving and Happiness
Charitable Giving and HappinessCharitable Giving and Happiness
Charitable Giving and HappinessFaircom New York
 
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...Paul Brown
 
xoxooo tkmmm
xoxooo tkmmmxoxooo tkmmm
xoxooo tkmmmceny2
 
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...Dave McClure
 
Practica 2 quimica organica -espol
Practica 2  quimica organica -espolPractica 2  quimica organica -espol
Practica 2 quimica organica -espolLissy Rodriguez
 
William Gross Sues Pimco for Hundreds of Millions
William Gross Sues Pimco for Hundreds of MillionsWilliam Gross Sues Pimco for Hundreds of Millions
William Gross Sues Pimco for Hundreds of MillionsTric Park
 

Viewers also liked (14)

How to increase traffic to your WordPress website.
How to increase traffic to your WordPress website. How to increase traffic to your WordPress website.
How to increase traffic to your WordPress website.
 
Moving to the Right Side of Safety
Moving to the Right Side of SafetyMoving to the Right Side of Safety
Moving to the Right Side of Safety
 
Guia De Estudio Digestivo
Guia De Estudio DigestivoGuia De Estudio Digestivo
Guia De Estudio Digestivo
 
Latin Dansları
Latin DanslarıLatin Dansları
Latin Dansları
 
The State of Facilities at Eastern Region Institutions JUNE16
The State of Facilities at Eastern Region Institutions JUNE16The State of Facilities at Eastern Region Institutions JUNE16
The State of Facilities at Eastern Region Institutions JUNE16
 
Charitable Giving and Happiness
Charitable Giving and HappinessCharitable Giving and Happiness
Charitable Giving and Happiness
 
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...
Challenging our Notions of Learning: Understanding How Web 2.0 Technology Wor...
 
Torque
TorqueTorque
Torque
 
Jvm mbeans jmxtran
Jvm mbeans jmxtranJvm mbeans jmxtran
Jvm mbeans jmxtran
 
xoxooo tkmmm
xoxooo tkmmmxoxooo tkmmm
xoxooo tkmmm
 
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...
Ultimate Platform Hotness Smackdown (Twitter, Facebook, iPhone, Native Web / ...
 
God Is Forgiving
God Is ForgivingGod Is Forgiving
God Is Forgiving
 
Practica 2 quimica organica -espol
Practica 2  quimica organica -espolPractica 2  quimica organica -espol
Practica 2 quimica organica -espol
 
William Gross Sues Pimco for Hundreds of Millions
William Gross Sues Pimco for Hundreds of MillionsWilliam Gross Sues Pimco for Hundreds of Millions
William Gross Sues Pimco for Hundreds of Millions
 

Recently uploaded

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power
 
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxAnne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxnoorehahmad
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.KathleenAnnCordero2
 
James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !risocarla2016
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGYpruthirajnayak525
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...marjmae69
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxaryanv1753
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxCarrieButtitta
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Escort Service
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comsaastr
 
call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@vikas rana
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...漢銘 謝
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 

Recently uploaded (20)

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
 
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxAnne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
 
James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptx
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptx
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
 
call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 

Testing for infrastructure as code for AnsibleFest 2016

  • 1. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Testing for Infrastructure as Code A Beginner's Pattern Presented by: Mike Caspar Incremental Infrastructure Coach
  • 2. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence The Audience?
  • 3. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Caspar Computer Services Inc. -- Innovative Solutions since 1984 - - Caspar.NET (5 cities in Canada / 10 years)
  • 4. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Why am I here?
  • 5. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence How do we start? Very basic understanding of Ansible Inventory & Groups A sample environment A starting pattern (The Test/Maintain Loop) Moving machines between environments Integrating Testing into the process (TDD for Infrastructure) Q & A
  • 6. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Physical Servers Virtual Servers Ansible works with both.
  • 7. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Applications… Not servers.
  • 8. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Physical and Virtual Infrastructure Production Development Staging (sort of)
  • 9. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Inventory - Folders by Application Name WALDO and GROVER are Application names… Why is this important ?
  • 10. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Inventory - Host Location and Types City Env.
  • 11. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Application - Group Variables --- # Playbook: GROVER_maintain_proxy.yml # This playbook Maintains the GROVER Application - name: ensure hosts are setup correctly on proxy servers in yyz hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod remote_user: root
  • 12. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Tests can be attached and versioned along with a specific version of Infrastructure (think... testing & rollbacks) Source Control…. Why ?
  • 13. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Host Names not IP Addresses ! (virtual machines)
  • 14. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence group_vars matching basics Playbook hosts + Inventory + group_vars + --limit
  • 15. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence group_vars matching basics Playbook hosts + Inventory + group_vars + --limit - name: ensure hosts are setup correctly on proxy servers in yyz hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod remote_user: root Playbook Inventory group_vars [GROVER_yyz_proxy_prod] yyzproxy1.caspar.com [GROVER_yyz_webservers_prod] web1.caspar.com
  • 16. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence The Test/Maintain Loop _test (govern) _maintain (dev) _setup (injected once)
  • 17. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence The continual loop ( Dev/Test Continuous Loop) APP_Maintain_serverType.yml APP_Test_serverType.yml APP_Maintain_serverType.yml APP_Test_serverType.yml The Test/Maintain Loop
  • 18. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Adding a new Application (in dev/staging first) APP_maintain_serverType.yml APP_test_serverType.yml APP_setup_serverType.yml (injected into loop only once). APP_test_serverType.yml The Test/Maintain Loop ( _setup injected only once ) _test (govern) _maintain (dev)
  • 19. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence --- # Playbook: GROVER_maintain_proxy.yml # This playbook Maintains the GROVER Application - name: ensure hosts are setup correctly on proxy servers in yyz hosts: GROVER_yyz_proxy_staging, GROVER_yyz_proxy_dev, GROVER_yyz_proxy_prod remote_user: root roles: - { role: GROVER-common } - { role: GROVER-users } - { role: GROBER-firewalls } tags: ['security'] } - { role: COMMON-newrelic, state: present, tags: ['monitoring'] } - { role: COMMON_puppet_agent, state: absent } - name: ensure hosts are setup correctly on proxy servers in yul hosts: GROVER_yul_proxy_staging, GROVER_yul_proxy_dev, GROVER_yul_proxy_prod remote_user: root roles: - { role: GROVER-common } - { role: GROVER-users } - { role: GROBER-firewalls } tags: ['security'] } - { role: COMMON-newrelic, state: present, tags: ['monitoring'] } - { role: COMMON_puppet_agent, state: absent } Notice the Application Name
  • 20. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence We decide when a machine is in Dev/Staging/Production (not physical location) Production Development Staging (sort of) To move a machine from Staging to Production…. Move it to another Inventory and run APP_maintain_
  • 21. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_test_proxy.yml ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_test_proxy.yml ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_test_proxy.yml ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_test_proxy.yml --limit a.host.com ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_test_proxy.yml --limit a.host.com ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_test_proxy.yml --limit a.host.com ansible-playbook -i Inventory/GROVER/yyz/dev/GROVER_maintain_proxy.yml ansible-playbook -i Inventory/GROVER/yyz/staging/GROVER_maintain_proxy.yml ansible-playbook -i Inventory/GROVER/yyz/prod/GROVER_maintain_proxy.yml Example commands White - Dev Blue - QA/Test Orange - Governance/Ops
  • 22. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Be careful of role defaults Empty Strings Length of group_vars tag
  • 23. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Why test_ instead of --check?
  • 24. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence TDD - Test Driven Development (learned from the Software Community) THINK ! Write a Failing Test Refactor Make it Pass http://www.extremeprogramming.org/rules/testfirst.html
  • 25. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Why is this a useful way to start? ● New apps are not re-deployed, the machines simply move inventory location ● tests have already run many times ● Testing and Governance work can be done in parallel to development tasks ● Development teams know right away if they broke something before and/or after ! ● Ability to use TDD software concepts for hardware ● Infrastructure can contain a version with matching tests
  • 26. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence T.D.D. concepts for Infrastructure To truly do Incremental Infrastructure delivery, we must have an automated way to know that we haven’t broken something else in the system when we make changes. The key is finding a method to allow constant evolution of our code base (infrastructure). We do not need to reinvent an approach. Test Driven Development concepts have proven effective in incremental software delivery and can be re-used effectively for infrastructure as code.. Mike Caspar, 2016
  • 27. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Git Repository for Sample Project Sample project file(s) available here… https://github.com/MikeCaspar/ansibleFest2016SFO Mike Caspar, 2016
  • 28. © Mike Caspar, 2016 Testing for Infrastructure as Code by Mike Caspar is licenced under an Attribution-ShareAlike 4.0 International licence Mike Caspar Incremental Infrastructure Coach Enterprise agile Coach email: mike@caspar.com twitter: @mikecaspar blog: http://mike- caspar.blogspot.com