Jon Lauridsen
Jon Lauridsen

Reputation: 2678

How to ensure Chef nodes and EC2 instances are in sync?

So, using knife we can create an EC2 instance and get its corresponding Chef node to show up on the Chef server, all with a single command. So far so good!

But do you have a tool or workflow for validating the link between instance and node? I had manually deleted an EC2 instance and so ended up with an orphaned Chef node.. it seems to me if I had a complicated network of instances I could've missed that. Or do you entirely bypass this by having a hard rule that no-one ever messes with EC2 instances directly, or something similar?

I'm new to Chef if it's not obvious, curious to understand how using Chef scales.

Upvotes: 1

Views: 199

Answers (1)

coderanger
coderanger

Reputation: 54191

Chef records when a node last checked in under node['ohai_time'] so you can use that to filter down results when using Chef for service discovery. A better option is to not use Chef for service discovery in favor of a tool built for it like ZooKeeper or Consul. Other than that, having orphaned data isn't really a huge deal so I generally ignore it. In the past I've also hooked up ASG scaling events to remove the associated node and client. I've also seen people put a script on the machine to be run on shutdown that removes its own node and client, though this can still leave orphans every now and then.

Upvotes: 2

Related Questions