HashiCorp Packer
HashiCorp Packer Basics
Mutable Infrastructure
In this lesson, we’ll explore how HashiCorp Packer integrates into application deployment by comparing mutable and immutable infrastructure paradigms. Understanding mutable infrastructure is the first step toward seeing the advantages Packer brings.
What Is Mutable Infrastructure?
Mutable infrastructure refers to servers (physical or virtual) that are continuously updated and modified after initial provisioning. A typical workflow looks like this:
- Develop your application code.
- Provision a server instance.
- Install the operating system (e.g., CentOS, Fedora, Ubuntu).
- Install packages and dependencies.
- Harden and secure the server (firewall rules, user permissions).
- Deploy and start your application.
- Maintain with ongoing patches, upgrades, and configuration tweaks.
Each in-place change mutates the system state, and over time, these mutations can lead to inconsistencies across servers.
while (alive) {
eat();
sleep();
code();
repeat();
}
Challenges of Mutating Live Servers
Applying updates or security hotfixes directly on running servers may work at small scale but leads to:
- Human error: Manual updates on many servers increase the risk of typos and missed steps.
- Configuration drift: Minor differences accumulate, causing environments to diverge and making debugging harder.
Automation tools like Ansible mitigate some risks by orchestrating parallel updates. However, since servers still mutate in place, drift can persist.
Warning
Relying solely on mutable operations can lead to untracked changes and compliance issues due to hidden configuration drift.
Comparing Mutable vs Immutable Infrastructure
Aspect | Mutable Infrastructure | Immutable Infrastructure |
---|---|---|
Update process | In-place patches and upgrades | Replace entire hosts or containers |
Reproducibility | Prone to configuration drift | Consistent, versioned images |
Recovery | Rollbacks can be error-prone | Quick rollback by redeploying a known-good image |
Tooling examples | Ansible, Chef, Puppet | HashiCorp Packer, Docker, Kubernetes, Terraform |
Note
Immutable infrastructure patterns use tools like Packer to bake golden images, eliminating in-place mutations and ensuring consistency across environments.
References
Watch Video
Watch video content