Infrastructure as
Code
Mike McGarr, Director of Learn DevOps
Blackboard, Inc.
ABOUT ME
Mike McGarr
Director of Learn DevOps
Blackboard Inc.
michael.mcgarr@blackboard.com
I have been at Blackboard for ...
LEARN DEVOPS TEAM
Purpose: Provide development support to the rest of
Learn‟s Product Development (PD) team.
Includes:
• B...
ENTERPRISE
APPLICATIONS
Problems:
• Manually managed
• Little/No Version
Control
• No history/context
DATA CENTER
Problems:
• Few knew how to run
CM
• Fewer knew how to fix
CM tool
• Lots of firefighting to
resolve CM issues
FIREFIGHTING
INFRASTRUCTURE AS
CODE
Automate the creation and maintenance of
servers (to the farthest extent possible)
• Build from sou...
TOOLS
CONFIGURATION
SYNCHRONIZATION
http://martinfowler.com/bliki/ConfigurationSynchronization.html
CONFIGURATION
DRIFT
http://kief.com/configuration-drift.html
NO MANUAL
CHANGES
http://www.agileweboperations.com/devops-protocol-no-manual-changes
PHOENIX SERVERS
http://martinfowler.com/bliki/PhoenixServer.html
IMMUTABLE SERVERS
http://martinfowler.com/bliki/ImmutableServer.html
REMINDER:
CULTURE FIRST
Simple
Example
Infrastructure as Code
BUILD A
JENKINS SERVER
CHEF‟S
ARCHITECTURE
CREATE COOKBOOK
http://youtu.be/Yu3--aljnJ0
VAGRANT
$> vagrant box add
$> vagrant init
$> vagrant up
$> vagrant ssh
$> vagrant provision
$> vagrant suspend
$> vagrant...
VAGRANT UP
http://youtu.be/I0Kd7mzEOD4
USE CHEF
http://youtu.be/UhXWrQvwsyE
INSTALLING JENKINS
INSTALL JDK VIA
CHEF
1. Include Java default recipe (recipe/default.rb)
2. Add cookbook dependency (metadata.rb)
3. Downlo...
INSTALL JDK
http://youtu.be/Pt7cg3oa4Hs
0%
http://youtu.be/Pt7cg3oa4Hs
ADD JENKINS USER
http://youtu.be/2VhvHXPKR6M
REUSE LIBRARIES
SECURITY
templates/defaults/port_jenkins.erb
recipes/default.rb
YUM REPOSITORY
recipes/default.rb
INSTALL PACKAGE
SERVICE IS RUNNING
LEARN CHEF
Software Server
Craftsmen
CONFIGURATION
WORKFLOW
VERSION CONTROL
https://www.youtube.com/watch?v=ZDR433b0HJY
$> git init
$> git add .
$> git commit –m “new commit”
$> git ...
DEPENDENCY
MANAGEMENT
Tools:
Berkshelf
librarian-chef
UNIT TESTING
chefspec
(ruby gem)
https://github.com/acrmp/chefspec
Test a cookbook
fast and from
anywhere
spec/default_spe...
CONTINUOUS
TESTING
guard
(ruby gem)
https://github.com/guard/guard
When a local file
changes, then
run unit tests.
Guardfi...
INTEGRATION
TESTING
test kitchen
(ruby gem)
https://github.com/opscode/test-kitchen
Run and test
cookbook in
Vagrant or LX...
STATIC ANALYSIS
foodcritic
(ruby gem)
http://acrmp.github.io/foodcritic/
Style guide and
find defects in
cookbook source
c...
CONTINUOUS
INTEGRATION
Jenkins
(Java app)
When a change
is checked in,
then run tests
and deploy to
Chef Server.
Best Practices
Infrastructure as Code
FORWARD ONLY
AVOID SCRIPTING
SEPARATE CONFIG
FROM DATA
USE & BUILD
PACKAGES
https://github.com/jordansissel/fpm
LEARN TO PROGRAM
Ops acting like developers…
Learn the language!
Learn the environment:
• rvm
• rbenv
• gems
• bundler
THANK YOU!
Mike McGarr
Director of Learn DevOps
Blackboard Inc.
michael.mcgarr@blackboard.com
@jmichaelmcgarr
http://early...
Upcoming SlideShare
Loading in...5
×

Infrastructure as Code (BBWorld/DevCon13)

2,484

Published on

My presentation on Infrastructure as Code from BBWorld/DevCon 2013 in Las Vegas

Published in: Technology
1 Comment
7 Likes
Statistics
Notes
No Downloads
Views
Total Views
2,484
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
88
Comments
1
Likes
7
Embeds 0
No embeds

No notes for slide
  • 2000+ virtual machinesHundreds of learn instancesHundreds of test agentsIn-house CM tool
  • Constantly fighting firesResulted from high technical debtImpact to team:High WIPContext switchingLarge backlogImage: http://www.ctif.org/CTIF-Commission-Rescue-and-Fire
  • If your question is Puppet vs. Chef, the answer is yes.Advantages:Provide DSL (easier to read)Community for helpOpen source, corporate backingHandles errors, etc.
  • ConvergenceIdempotence
  • Manual changes lead to driftGoal: Avoid Configuration Drift
  • Fully capable of rebuilding a server from scratch at any timeEasier than troubleshooting unique issuesImage: http://coverlaydown.com/2013/02/the-phoenix-rises-on-coming-back-and-moving-forward/
  • The logical evolution of Phoenix Servers
  • DevOps is not about tools, it’s about culture.…however, tools can change behavior, …and behavior change leads to culture change.
  • Ruby Wrapper to VirtualBox (and others)Simplifies Local VM integrationUnderstands CM ToolsPlugin API
  • Chef client installed on machine<Vagrant boots machine, passes runlist to client>Describe Chef Server briefly
  • Discuss how some developer best practices can/should apply to ops.
  • Depict how changes are made:Change locally, in VagrantUnit test changes/regressionsRun Integration TestsCommit to Git (pre-commit hook to ensure incremented version)Jenkins runs testsIf successful, publish to Chef Server (staging environment)Staging environment updates (daemon or push)Manual testing…if all goodPromote change in Jenkins to production environmentServers update (daemon/push)
  • Communication mechanism
  • Requires:Updates to GemfileTo Run: bundle install && bundle exec rspec --color --format documentationUnit Tests: FIRSTFastIndependentRepeatableSelf-VerifyingTimely
  • Runs
  • Common gotcha…Removing a resource from
  • Script has explicit OS dependencies
  • Don’t forget to backup data prior to upgrade.
  • Infrastructure as Code (BBWorld/DevCon13)

    1. 1. Infrastructure as Code Mike McGarr, Director of Learn DevOps Blackboard, Inc.
    2. 2. ABOUT ME Mike McGarr Director of Learn DevOps Blackboard Inc. michael.mcgarr@blackboard.com I have been at Blackboard for 8 months. Software Engineer for 12+ years Founder of the DC Continuous Integration, Delivery and Deployment Meetup
    3. 3. LEARN DEVOPS TEAM Purpose: Provide development support to the rest of Learn‟s Product Development (PD) team. Includes: • Build/Release Engineering • Manage Enterprise Applications • Manage Data Center • Help desk for PD
    4. 4. ENTERPRISE APPLICATIONS Problems: • Manually managed • Little/No Version Control • No history/context
    5. 5. DATA CENTER Problems: • Few knew how to run CM • Fewer knew how to fix CM tool • Lots of firefighting to resolve CM issues
    6. 6. FIREFIGHTING
    7. 7. INFRASTRUCTURE AS CODE Automate the creation and maintenance of servers (to the farthest extent possible) • Build from source control • Utilize open source tools • Ensure testability A practice popularized by the DevOps movement.
    8. 8. TOOLS
    9. 9. CONFIGURATION SYNCHRONIZATION http://martinfowler.com/bliki/ConfigurationSynchronization.html
    10. 10. CONFIGURATION DRIFT http://kief.com/configuration-drift.html
    11. 11. NO MANUAL CHANGES http://www.agileweboperations.com/devops-protocol-no-manual-changes
    12. 12. PHOENIX SERVERS http://martinfowler.com/bliki/PhoenixServer.html
    13. 13. IMMUTABLE SERVERS http://martinfowler.com/bliki/ImmutableServer.html
    14. 14. REMINDER: CULTURE FIRST
    15. 15. Simple Example Infrastructure as Code
    16. 16. BUILD A JENKINS SERVER
    17. 17. CHEF‟S ARCHITECTURE
    18. 18. CREATE COOKBOOK http://youtu.be/Yu3--aljnJ0
    19. 19. VAGRANT $> vagrant box add $> vagrant init $> vagrant up $> vagrant ssh $> vagrant provision $> vagrant suspend $> vagrant destroy
    20. 20. VAGRANT UP http://youtu.be/I0Kd7mzEOD4
    21. 21. USE CHEF http://youtu.be/UhXWrQvwsyE
    22. 22. INSTALLING JENKINS
    23. 23. INSTALL JDK VIA CHEF 1. Include Java default recipe (recipe/default.rb) 2. Add cookbook dependency (metadata.rb) 3. Download Java cookbook 4. Run „vagrant provision‟
    24. 24. INSTALL JDK http://youtu.be/Pt7cg3oa4Hs 0% http://youtu.be/Pt7cg3oa4Hs
    25. 25. ADD JENKINS USER http://youtu.be/2VhvHXPKR6M
    26. 26. REUSE LIBRARIES
    27. 27. SECURITY templates/defaults/port_jenkins.erb recipes/default.rb
    28. 28. YUM REPOSITORY recipes/default.rb
    29. 29. INSTALL PACKAGE
    30. 30. SERVICE IS RUNNING
    31. 31. LEARN CHEF
    32. 32. Software Server Craftsmen
    33. 33. CONFIGURATION WORKFLOW
    34. 34. VERSION CONTROL https://www.youtube.com/watch?v=ZDR433b0HJY $> git init $> git add . $> git commit –m “new commit” $> git remote add git:git@... $> git push origin master Chef/Puppet Server is not Version Control!!
    35. 35. DEPENDENCY MANAGEMENT Tools: Berkshelf librarian-chef
    36. 36. UNIT TESTING chefspec (ruby gem) https://github.com/acrmp/chefspec Test a cookbook fast and from anywhere spec/default_spec.rb
    37. 37. CONTINUOUS TESTING guard (ruby gem) https://github.com/guard/guard When a local file changes, then run unit tests. Guardfile
    38. 38. INTEGRATION TESTING test kitchen (ruby gem) https://github.com/opscode/test-kitchen Run and test cookbook in Vagrant or LXC container. .kitchen.yml
    39. 39. STATIC ANALYSIS foodcritic (ruby gem) http://acrmp.github.io/foodcritic/ Style guide and find defects in cookbook source code.
    40. 40. CONTINUOUS INTEGRATION Jenkins (Java app) When a change is checked in, then run tests and deploy to Chef Server.
    41. 41. Best Practices Infrastructure as Code
    42. 42. FORWARD ONLY
    43. 43. AVOID SCRIPTING
    44. 44. SEPARATE CONFIG FROM DATA
    45. 45. USE & BUILD PACKAGES https://github.com/jordansissel/fpm
    46. 46. LEARN TO PROGRAM Ops acting like developers… Learn the language! Learn the environment: • rvm • rbenv • gems • bundler
    47. 47. THANK YOU! Mike McGarr Director of Learn DevOps Blackboard Inc. michael.mcgarr@blackboard.com @jmichaelmcgarr http://earlyandoften.wordpress.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×