PREPARE TO CREATE AN EC2 INSTANCE
sudo gem install knife-ec2
nano ~/chef-repo/.chef/knife.rb (notice the EC2 credentials listed)
# THESE CREDENTIALS ENABLE KNIFE TO CREATE INSTANCES ON EC2:
knife[:aws_access_key_id] = "Your AWS Access Key"
knife[:aws_secret_access_key] = "Your AWS Secret Access Key"
ubuntu 11.04 x64 EBS backed us-west-1 = ami-136f3c56 (from http://alestic.com/)
knife ec2 server create -I ami-136f3c56 -f t1.micro -g default -S john-aws -i ~/chef-repo/.chef/john-aws.pem -x ubuntu --region us-west-1 -Z us-west-1a
[Sun, 19 Jun 2011 08:15:49 +0000] INFO: *** Chef 0.10.0 ***
[Sun, 19 Jun 2011 08:15:49 +0000] INFO: Client key /etc/chef/client.pem is not present - registering
[Sun, 19 Jun 2011 08:16:12 +0000] INFO: Report handlers complete
knife list client
knife list node
TERMINATE THE INSTANCE WITH AMAZON
knife delete client i-UNIQUEID
knife delete node i-UNIQUEID
BEST PRACTICE is to manage chef repositories and cookbooks with Git version control
knife won't work without it
# apt-get install git
# exit
$ cd
$ git clone git://github.com/opscode/chef-repo.git
http://community.opscode.com/cookbooks
knife cookbook site install getting-started
TO CREATE AN AMAZON INSTANCE USING AMAZON API
http://aws.amazon.com/documentation/
ec2-run-instances ami-a54d67d1 --instance-type m1.large --region eu-west-1 --key pstam-keypair
knife bootstrap ec2-.....eu-west-1.compute.amazonaws.com -r "role[store]" -x ubuntu -i /home/ubuntu/.ssh/ec2_ssh_key --sudo
Micro Instance API name: t1.micro
613 MB memory , Up to 2 EC2 Compute Units (for short periodic bursts)
EBS storage only
32-bit or 64-bit platform
I/O Performance: Low
knife configure -i
knife cookbook site list
knife cookbook site show haproxy
knife cookbook site download haproxy
knife cookbook upload haproxy
knife data bag list
knife data bag show itemInDatabag (if you have a specific "itemInDatabag" item in the databag)
knife data bag delete itemInDatabag itemToBeDeleted
knife node list
knife search node "platform:ubuntu" -a virtualization
http://wiki.opscode.com/display/chef/Knife
mkdir -p ~/.chef
sudo cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
sudo chown -R $USER ~/.chef
hef-server > knife configure -i
Where should I put the config file? [~/.chef/knife.rb]
Please enter the chef server URL: [http://localhost:4000]
Please enter a clientname for the new client: [bob]
On a node running the Chef Client, the private key is generally stored in /etc/chef/client.pem
For an administrator using knife, the private key is generally stored in ~/.chef/USERNAME.pem
sudo chef-client -V (run chef client in verbose mode to see all actions)
Chef Server PORT 4000
Chef Server WEB UI PORT 4040