4 ms·
Nope, CloudFormation is for infrastructure provisioning. Configuration management is still valuable post-boot. I've been using CloudFormation in conjunction w
by nethergoat 16y ago
Nope, CloudFormation is for infrastructure provisioning. Configuration management is still valuable post-boot.
I've been using CloudFormation in conjunction with Chef - they're complementary tools, really.
- g123g 16y agoCan you share some example of how you are using them together. I am currently using Python scripts with boto to bring up the instances and doing all kinds of configuration stuff on them. Just wanted to see if there is any better way of doing this.
- nethergoat 16y agoBasically, you just need to pass a Chef bootstrap script in through the instance's user-data. Knife, a Chef management and interaction tool, provides several bootstrap scripts you could use as a starting point: https://github.com/opscode/chef/tree/master/chef/lib/chef/knife/bootstrap https://github.com/opscode/chef/tree/master/chef/lib/chef/kn... Let's use the Ubuntu 10.04 gem bootstrap script as an example (https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb https://github.com/opscode/chef/blob/master/chef/lib/chef/kn...). The basic steps to use this with Chef would be: (Note that this assumes you have a Chef server or are using the Opscode Platform. There's also a server-less option called "chef-solo" that you can use) 1. Create an appropriate first-boot.json to be used by the node(s). This will probably just be a "run_list" with entries like "role[app_server]" (function) and "role[production]" (environment). 2. Replace line 42 of the bootstrap script with your first-boot.json. Since this bootstrap script is actually a template, make sure to replace all other .erb stuff ("<%= %>") as appropriate. 3. JSON-encode the bootstrap script (handy tool: http://artur.ejsmont.org/blog/content/ultimate-web-encoder-decoder http://artur.ejsmont.org/blog/content/ultimate-web-encoder-d...) 4. Build your CF template, placing the JSON-encoded script in the "user data" section of your instance/auto-scaling group(s). 5. Instantiate your CF stack If you'd like to use Chef for the entire lifecycle of your instances, just include a Chef recipe for running chef-client via cron every, say, 5 minutes. This allows changes to be propagated automatically in a pull style. Done right, the end result is a complete, Chef-managed environment provisioned from bare metal using just one command.
- g123g 16y agoCool, thanks a lot for sharing. Your post has given me the motivation to start learning Chef. Maybe you can blog about it somewhere to help wanna be cloud programmers like me.
- xaque208 16y agoYou can also bootstrap using Puppet. Basically you generate a template that you can use to upload to CF and it will just run the bootstrap script from the UserData section when the instance is started. See the wiki here: http://projects.puppetlabs.com/projects/puppet/wiki/Bootstrapping_AWS_CloudFormation http://projects.puppetlabs.com/projects/puppet/wiki/Bootstra...