Upgrade to Pro — share decks privately, control downloads, hide ads and more …

So You Still Cowboy Code Your Infrastructure...

So You Still Cowboy Code Your Infrastructure...

We all know not to cowboy code our applications, yet it’s the Wild West when working on building and maintaining your servers. In my talk, I will discuss provisioning, deployment, and development setup for infrastructure. By working through a case study of rebuilding my company’s infrastructure, I will demonstrate the advantages of building servers in a development environment. Using this workflow, you will be able to see how easy it is to build and maintain infrastructure through sane and logical development practices.

Zack Tollman

July 26, 2014
Tweet

More Decks by Zack Tollman

Other Decks in Technology

Transcript

  1. So You Still
    Cowboy Code
    Your Infrastructure…
    Zack Tollman | The Theme Foundry | @tollmanz

    View Slide

  2. !
    Cowboy Coding

    View Slide

  3. No testing

    View Slide

  4. Live edits

    View Slide

  5. No process

    View Slide

  6. Jack Bauer Coding

    View Slide

  7. Crass
    Unpredictable
    Collateral Damage

    View Slide

  8. “Sir, I have a way to _______,
    but it might involve _______.”

    View Slide

  9. It started 18 months ago

    View Slide

  10. Manage the servers they said

    View Slide

  11. My history of live edits
    is not good

    View Slide

  12. View Slide

  13. > top
    Brain wants

    View Slide

  14. > service nginx stop
    Fingers type

    View Slide

  15. rewrite
    ^/punchcut/?$
    /wordpress-themes/paperpunch/ permanent

    View Slide

  16. rm /srv/www/wp-config.php

    View Slide

  17. How can I build something that
    saves me from myself?

    View Slide

  18. Peace of mind with
    Local Development

    View Slide

  19. Develop in a non-remote
    environment

    View Slide

  20. Mistakes only hurt my ego

    View Slide

  21. Vagrant

    View Slide

  22. Reproducible development
    environment

    View Slide

  23. Test server locally

    View Slide

  24. View Slide

  25. Best approximation

    View Slide

  26. Allows me to see what likely
    happens when I do something

    View Slide

  27. Keeping me off the command line with
    Provisioning

    View Slide

  28. Set of actions
    to prepare a server

    View Slide

  29. Idempotence
    Apply the same procedure;
    get the same result

    View Slide

  30. Guarantees a server’s state

    View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. View Slide

  35. View Slide

  36. Documents your server

    View Slide

  37. Allows for versioning

    View Slide

  38. I can still mess this up so let’s talk about
    Deployment

    View Slide

  39. Process of making
    software available

    View Slide

  40. Clone/pull
    Move files
    Handle permissions
    Run build tasks

    View Slide

  41. Automate the headaches away

    View Slide

  42. Fabric
    Vlad the!
    Deployer

    View Slide

  43. View Slide

  44. That’s neat, but how do we
    Integrate These Tools

    View Slide

  45. Let’s add Fail2Ban to our site

    View Slide

  46. Server software
    New logs
    New configs
    Application changes
    * Bad config blocks everyone

    View Slide

  47. WordPress, plugins,
    and theme code
    App

    View Slide

  48. Salt state files that describe
    the state of the server
    App States

    View Slide

  49. Data for specific servers
    (e.g., more Memcached RAM
    for production)
    App States Pillar

    View Slide

  50. Fabric commands for
    deployment tasks
    App States Pillar Fab

    View Slide

  51. Server environments
    App States Pillar Fab
    Local/Vagrant Staging Production

    View Slide

  52. App States Pillar Fab

    View Slide

  53. App States Pillar Fab
    Write state

    View Slide

  54. Add config to Pillar
    App States Pillar Fab

    View Slide

  55. App States Pillar Fab
    Local Staging Production
    Deploy server updates locally
    fab local server.update

    View Slide

  56. App States Pillar Fab
    Local Staging Production

    View Slide

  57. App States Pillar Fab
    Test that changes
    were applied
    Local Staging Production

    View Slide

  58. App States Pillar Fab
    Local Staging Production
    Install and modify
    WP Fail2Ban plugin

    View Slide

  59. App States Pillar Fab
    Local Staging Production
    fab local app.deploy
    Deploy app updates locally

    View Slide

  60. App States Pillar Fab
    Local Staging Production
    Test, test, test, test,
    take a break,
    test, test, test, test

    View Slide

  61. App States Pillar Fab
    Local Staging Production
    Changes made to 3 repos
    and applied locally

    View Slide

  62. App States Pillar Fab
    Local Staging Production
    Apply changes to staging
    environment

    View Slide

  63. App States Pillar Fab
    Local Staging Production
    fab staging server.update
    fab staging app.deploy

    View Slide

  64. App States Pillar Fab
    Local Staging Production
    Verify changes in real environment
    Verify deployment procedure

    View Slide

  65. App States Pillar Fab
    Local Staging Production
    Apply changes to production

    View Slide

  66. App States Pillar Fab
    Local Staging Production
    fab production server.update
    fab production app.deploy

    View Slide

  67. Adopt procedures that
    improve stability

    View Slide

  68. Use the tools that
    work for you and your team

    View Slide

  69. speakerdeck.com/tollmanz/so-you-still-cowboy-
    code-your-infrastructure-dot-dot-dot

    View Slide