I have ami’s that I’m creating from chef scripts, and I would like them to
re-register themselves with my chef server on boot. It looks as though it
ought to be a pretty straightforward thing, but I haven’t seen any examples
out there. All of the examples appear to assume a base image without
chef-client and all it’s goodness. So my question is, what is the minimum
required to have an instance spun up from an ami register and come under
control of chef server? I’d like to stuff that into CloudFormation
UserData and speed up my deployments.
You can use cfn-init to install the omnibus chef-client, copy the validation.pem from S3 (unless it's pre-baked in your ami), and write a client.rb config file and a first-run.json.
Then you just need a cfn command of 'chef-client -c -j
AWS definitely has some example cfn code to do something like this.
I have ami's that I'm creating from chef scripts, and I would like them to re-register themselves with my chef server on boot. It looks as though it ought to be a pretty straightforward thing, but I haven't seen any examples out there. All of the examples appear to assume a base image without chef-client and all it's goodness. So my question is, what is the minimum required to have an instance spun up from an ami register and come under control of chef server? I'd like to stuff that into CloudFormation UserData and speed up my deployments.
This presentation from re:Invent is a little old (like please don't
install Chef directly from Rubygems anymore in this way), but it's
pretty similar to what you want to do.
I have ami's that I'm creating from chef scripts, and I would like them to
re-register themselves with my chef server on boot. It looks as though it
ought to be a pretty straightforward thing, but I haven't seen any examples
out there. All of the examples appear to assume a base image without
chef-client and all it's goodness. So my question is, what is the minimum
required to have an instance spun up from an ami register and come under
control of chef server? I'd like to stuff that into CloudFormation UserData
and speed up my deployments.
what is the minimum required to have an [Amazon EC2] instance
spun up from an ami register and come under control of chef
server?
Such requirements for a virtual machine managed by AWS are no
different than those for any other physical or virtual machine.
Your question might be better asked as, "How does one bootstrap
a node?" or "How does one bootstrap a node in an unattended
manner?"
Assuming that you want the new machine to initiate contact with
the Chef server rather than having something on the Chef server
or another chef workstation connect to then new machine and start
the process, you'll need to have chef-client installed on the new
machine and for it to connect to and authenticate with a Chef
server, providing a run list and unique node name. There are
multiple ways to accomplish that.
I perform Chef bootstrapping of CloudFormation-launched EC2
instances by using a combination of CloudInit and the CloudFormation helper scripts to create a file containing a
copy of the server's chef-validator key, download and install
the applicable chef-client package, and initiate a chef-client
run. I trigger all of that upon first boot by providing user
data to the machine for CloudInit to read by defining it in
the UserData section of the Properties section of my
instance's definition in my stack template. For Ubuntu machines,
I use one of the Ubuntu-provided AMIs, which have CloudInit
installed. For CentOS, I make my own AMI, starting with a machine
launched from one of the CentOS maintainers' images, enabling the
EPEL repository, installing the cloud-init package, shutting down,
and imaging that machine.
Also, when asking a question on a technical mailing list, putting
your question in the message subject helps people know what
information you seek and thus makes it more likely that those who
can help will read the body of your message. It also helps other
people who have the same question find the answer later.