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

Chef + Environments = Safer Infrastructure

Chef + Environments = Safer Infrastructure

This is for the talk I gave at DevOps DC on 1/8/13. It discusses how to migrate a change from development, staging, and finally production with cookbook versioning and rollbacks.

Seth Vargo

January 08, 2013
Tweet

More Decks by Seth Vargo

Other Decks in Technology

Transcript

  1. chef
    + environments
    safer infrastructure

    View Slide

  2. t
    f
    g
    sethvargo

    View Slide

  3. what’s an environment?

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  9. target specific
    environments

    View Slide

  10. $ knife search node "chef_environment:production"

    View Slide

  11. $ knife ssh "chef_environment:production" "reboot"

    View Slide

  12. default_attributes
    override_attributes
    cookbook_versions
    chef_type
    name
    description

    View Slide

  13. default_attributes
    override_attributes
    cookbook_versions
    chef_type
    name
    description

    View Slide

  14. lock cookbooks in
    production

    View Slide

  15. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : {
    "passenger_apache2" : "0.99.4"
    },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  16. “lock” cookbooks in
    staging

    View Slide

  17. {
    "name" : "staging",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : {
    "passenger_apache2" : "0.99.4"
    },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  18. unlock cookbooks in
    development

    View Slide

  19. {
    "name" : "development",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : { ... },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  20. updating a cookbook

    View Slide

  21. 1. test in development

    View Slide

  22. 2. promote in staging

    View Slide

  23. {
    "name" : "staging",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : {
    "passenger_apache2" : "0.99.4"
    },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  24. {
    "name" : "staging",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : {
    "passenger_apache2" : "0.99.4"
    },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  25. {
    "name" : "staging",
    "description" : "Production cluster in EC2",
    "cookbook_versions" : {
    "passenger_apache2" : "1.1.0" // major version bump
    },
    "override_attributes" : { ... },
    "default_attributes" : { ... }
    }

    View Slide

  26. $ knife dwim environments/staging.json
    1 knife-dwim: https://github.com/mpasternacki/knife-dwim

    View Slide

  27. 3. verify in staging

    View Slide

  28. 4. promote in production

    View Slide

  29. View Slide

  30. 1. run around
    screaming

    View Slide

  31. 2. demote in production

    View Slide

  32. 3. dance (optional)

    View Slide

  33. View Slide

  34. scenario:
    updating passenger

    View Slide

  35. default_attributes
    override_attributes
    cookbook_versions
    chef_type
    name
    description

    View Slide

  36. default_attributes
    override_attributes
    cookbook_versions
    chef_type
    name
    description

    View Slide

  37. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "override_attributes" : {
    "passenger" : {
    "version" : "2.1.4"
    }
    },
    }

    View Slide

  38. 1. test in development

    View Slide

  39. 2. promote in staging

    View Slide

  40. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "override_attributes" : {
    "passenger" : {
    "version" : "2.1.4"
    }
    },
    }

    View Slide

  41. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "override_attributes" : {
    "passenger" : {
    "version" : "2.1.4"
    }
    },
    }

    View Slide

  42. {
    "name" : "production",
    "description" : "Production cluster in EC2",
    "override_attributes" : {
    "passenger" : {
    "version" : "3.0.18" // major version bump
    }
    },
    }

    View Slide

  43. $ knife dwim environments/staging.json
    1 knife-dwim: https://github.com/mpasternacki/knife-dwim

    View Slide

  44. 3. verify in staging

    View Slide

  45. 4. promote in production

    View Slide

  46. chef
    + environments
    safer infrastructure

    View Slide

  47. t
    f
    g
    sethvargo

    View Slide