Configuration Drift • Manual ad-hoc changes and updates to servers that are not recorded • Servers in your infrastructure became more and more different from each others @_dcsg #MSOSCAMP
Snowflake Server • Long running servers • Difficult to reproduce • No consistency between servers • Lack of confidence in your systems • Hard to spin up another instance in the same state @_dcsg https://martinfowler.com/bliki/SnowflakeServer.html
Configuration Management Spin up Base Image Run Config Management Server in desire state Changes Edit config file Upgrade/install package … Running Server
Built Process Spin up Base Image Run Config Management Server in desire state Install packages Create folders Create user Upload app etc Run Config Management Repositories unavailable Package not locked to specific version
“An Immutable Server is a server, that once deployed, is never modified, merely replaced with a new updated instance.” - Kief Morris in ImmutableServer @_dcsg #MSOSCAMP
Immutable Servers • Final state image with everything baked in. • No changes after it’s built. • Include scripts to start the application at boot. • Easy to scale out, deploy and rollback • Trustable and testable • Easy to adopt A/B testing, Canary releases or Blue/Green deployments @_dcsg #MSOSCAMP
Immutable Server Build Process Run Config Management (puppet, chef, ansible) Bake In the App App Final Image Server in desire state configure application environment Spin up Base Image
Build Image Stages Flow Example Base Image OS Hardening Common tools (vim, htop, etc) etc Application Base Image Install necessary software to run the App Create user/folders Application Final Image Upload App Script to run App at boot System upgrades & Security updates Application security, package, configuration updates
• SnowFlake Servers • Inconsistent states between machine (Config Drifts) • Phoenix Serves • Avoids Config Drifts using CM Automation Tools • Can be built from scratch • Immutable Serves • Final image with everything baked in • After built cannot be modified • Can only be replaced with an updated instance Recap
“Packer is an open source tool for creating identical machine images for multiple platforms from a single source configuration.” What’s Packer? @_dcsg #MSOSCAMP
User Variables Can be defined from: • The command line • Environment Variables • From a file @_dcsg https://www.packer.io/docs/templates/user-variables.html
Run packer using only docker Builder > packer build -only=docker base-image.json > packer build -parallel=true base-image.json Run packer using both Builders in Parallel