|
|
Recommended UseThe current recommended way to launch EC2 instances for Chef is to use the Knife sub-commands. Rolling Your OwnIf you would like to roll your own Amazon EC2 AMIs with Chef preinstalled, you can follow the same steps that were used by Opscode. These are consistent with the general Installation instructions, and use a RubyGems installation of Chef.
Launch InstancesWe use Canonical's official Ubuntu images. Commands to launch an instance of the desired AMI are listed on those pages. Login and StartLog into the instance as ubuntu, make sure history will not be saved and su to root. Edit the sources and enable multiverse. Install Ruby and RubyGemsWe install Ruby from packages, but RubyGems from source, same as the Installation instructions for RubyGems. We also install the ec2-ami-tools, which come from multiverse. Install ChefInstall the Chef gem. We only need the client. You could opt to install Chef from distribution packages if you wish, see Installing Chef Client on Ubuntu or Debian for more information. Configure Chef ClientThis section could also be handled with the normal [RubyGems Bootstrap], but doing it manually leaves fewer artifacts to clean up We use Runit to manage the chef-client service with a RubyGems installation. Runit uses a 'run' script and a 'log/run' script. /etc/sv/chef-client/run /etc/sv/chef-client/log/run Install runit and set up the chef-client service: Clean upCopy EC2 ConfigurationYou will need to copy your EC2 certificates over with a config file. The pk.pem and cert.pem should be the contents of the appropriate files for your EC2 credentials. The config file should have the following values set: Source the EC2 config and set up some helper variables for creating the AMI name. Be sure to specify the correct ARCH for the instance type you're creating. Create the AMI BundleRegister and ReleaseThese steps use programs that are included in the ec2-api-tools. You will need to install these for your local workstation's Operating System. On your local workstation, repeat the variable export from above. Also make sure you are using the correct EC2 configuration. Then register the AMI manifest to generate a machine ID. Finally, if you are making the AMI available for anyone to use, set public permission.
|

3 Comments
comments.show.hideSep 07, 2010
Andrew Bruce
An alternative to doing the steps from "Copy EC2 configuration" is to use the automated AMI building features under Instance Actions in the AWS console. This also means you don't need the AMI tools package.
Nov 16, 2010
Michael Keirnan
You mention that "These AMIs reflect an older way of launching instances in EC2 for Chef."
Does this mean that the bootstrapped AMI approach and "knife ec2 instance data" will be deprecated?
Launching EC2 instances with knife is fine and works well for individual instances but not
for auto-scaling.
The use case I have in mind is an AWS auto-scaling setup whose launch config contains instance data
generated by "knife ec2 instance data 'role[foo]'". Does that seem reasonable?
Nov 17, 2010
Joshua Timberman
We don't have any plans to remove the instance data sub command for knife, so you can continue to implement EC2 instances with this process. We may not always keep the AMIs up to date.