Agent Wranglers

Servers Recommended

Replace servers instead of patching them

Build a new machine image for every change, start new servers from it and stop the old ones. Never change a running server by hand.

How to do it

Build the image in CI with a tool such as Packer, or ship a container image. Start the new servers, wait for their health checks, then stop the old ones. A server changed by hand drifts away from the code, and nobody can rebuild it the same way. Replace each server at least every 30 days, so the newest updates are always baked in.

Example

resource "aws_launch_template" "web" {
  image_id      = data.aws_ami.web_latest.id
  instance_type = "t4g.small"
}

resource "aws_autoscaling_group" "web" {
  min_size = 2
  max_size = 6
  launch_template {
    id      = aws_launch_template.web.id
    version = aws_launch_template.web.latest_version
  }
  instance_refresh {
    strategy = "Rolling"
    preferences { min_healthy_percentage = 100 }
  }
}

How to check

No running server is older than 30 days. Every server runs the image ID of the latest build.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers infrastructure playbook: https://agentwranglers.se/playbook/infrastructure/servers/immutable-servers.