[==] Added a Berksfile to install community cookbooks

See <http://berkshelf.com>
[==] Added a Gemfile to install Rubygems

Install required Rubygems with:

    $ bundle install
[==] Added a Vagrantfile

See <http://vagrantup.com>
[  ] Added a simple bootstrapping script

* Update packages
* Install curl and vim
* Install Chef with the ["omnibus"](http://www.opscode.com/chef/install/) installer
* Setup dummy files and empty folders for Chef
* Copy cookbooks from /tmp
[01] Added the simplest possible node configuration: install Nginx

Nginx will be installed from packages via the "nginx" [cookbook](https://github.com/opscode-cookbooks/nginx).

Launch the virtual machine:

    vagrant up

Download cookbooks locally with [Berkshelf](http://berkshelf.com):

    berks install --shims ./tmp/cookbooks

If you have problems with Berkshelf, just download them with `curl`:

    curl -# -L -k http://s3.amazonaws.com/community-files.opscode.com/cookbook_versions/tarballs/2059/original/ohai.tgz | tar xz -C tmp/cookbooks
    curl -# -L -k http://s3.amazonaws.com/community-files.opscode.com/cookbook_versions/tarballs/1863/original/build-essential.tgz | tar xz -C tmp/cookbooks
    curl -# -L -k http://s3.amazonaws.com/community-files.opscode.com/cookbook_versions/tarballs/1425/original/runit.tgz | tar xz -C tmp/cookbooks
    curl -# -L -k http://s3.amazonaws.com/community-files.opscode.com/cookbook_versions/tarballs/2056/original/nginx.tgz | tar xz -C tmp/cookbooks

Generate SSH configuration from Vagrant:

    vagrant ssh-config > tmp/vagrant_ssh_config

Upload cookbooks, bootstrap script and node config to virtual machine:

    HOST=webserver
    scp -F tmp/vagrant_ssh_config -r bootstrap.sh node*.json tmp/cookbooks $HOST:/tmp
    scp -F tmp/vagrant_ssh_config -r cookbooks $HOST:/tmp

Run the bootstrap script:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo bash /tmp/bootstrap.sh"

Run Chef:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo chef-solo -j /tmp/node.json"

Check (service status, curl, etc):

    ssh $HOST -F tmp/vagrant_ssh_config -t "sudo service nginx status"
    ssh $HOST -F tmp/vagrant_ssh_config -t "nginx -v"
    ssh $HOST -F tmp/vagrant_ssh_config -t "curl localhost"

Open the <http://33.33.33.33> URL in your browser.
[02] Changed node configuration to install specific Nginx version from source

    ssh $HOST -F tmp/vagrant_ssh_config -t "sudo killall -9 nginx"
    ssh $HOST -F tmp/vagrant_ssh_config -t "sudo apt-get remove nginx -y"
    ssh $HOST -F tmp/vagrant_ssh_config -t "sudo update-rc.d -f nginx remove"

    scp -F tmp/vagrant_ssh_config -r node.json $HOST:/tmp
    scp -F tmp/vagrant_ssh_config -r cookbooks $HOST:/tmp
    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo chef-solo -j /tmp/node.json"
[  ] Added a simplistic "application" cookbook

* Creates an Nginx configuration file
* Creates a simple HTML page (the "application")
[03] Added the "application" recipe to the node configuration

Upload the "application" cookbook and update node configuration to host:

    HOST=webserver
    scp -F tmp/vagrant_ssh_config -r node.json $HOST:/tmp
    scp -F tmp/vagrant_ssh_config -r cookbooks $HOST:/tmp

Run the bootstrap script:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo bash /tmp/bootstrap.sh"

Run Chef:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo chef-solo -j /tmp/node.json"
[04] Changed the HTML template to use Ohai attributes

The template for the HTML page is a regular ERb template, so we can fill in variables gathered by Chef on its run,
such as node name, Nginx version, etc.

Upload the updated cookbook to host:

    HOST=webserver
    scp -F tmp/vagrant_ssh_config -r cookbooks $HOST:/tmp

Run the bootstrap script:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo bash /tmp/bootstrap.sh"

Run Chef:

    time ssh -F tmp/vagrant_ssh_config -t $HOST "sudo chef-solo -j /tmp/node.json"
[05] Added support for EC2

Install the `knife-ec2` gem:

    gem install knife-ec2

To launch, provision and configure a webserver in EC2, run:

    $  time knife ec2 server create --node-name webserver \
                                    --config knife.rb \
                                    --ssh-user ubuntu \
                                    --run-list 'recipe[nginx],recipe[application]' \
                                    --groups webserver \
                                    --template-file ./bootstrap_ec2.erb \
                                    --flavor t1.micro

You'll need to provide the `knife-ec2` gem with AWS credentials:

    export AWS_ACCESS_KEY_ID=<your AWS access key>
    export AWS_SECRET_ACCESS_KEY=<your AWS secret access key>

Your SSH private key for accessing servers on EC2 should be present in (create it in the AWS console):

      ~/.ssh/<YOUR USERNAME>-ec2.pem

* The `knife-ec2` gem will launch the specified EC2 instance, based on [Ubuntu 12.04](https://cloud-images.ubuntu.com/precise/current/)
* It will perform a basic bootstrap via the `bootstrap_ec2.erb` template and install Chef on the machine
* The bootstrap process will download all required resources (cookbooks, node.json)
* The Chef run in solo mode will provisioning the virtual machine as a "webserver"

After the process is complete, open the _Public DNS Name_ URL in your web browser.

To terminate the server, run:

    knife ec2 server delete <Instance ID> --yes
[==] Added README