<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -30,8 +30,9 @@ common: &amp;common
   # SECURITY GROUP CONFIG
   ##########################################################
   # Set the default security group to apply firewall ingress rules to.
-  # Defaults, appropriately, to 'default' security group.
-  #group_name: 'default'
+  # Defaults to a group named from the 'application' Cap variable, and
+  # such a group is created by 'cap ec2:setup' by default as well.
+  #group_name: 'my_app'
 
   # Set the default security group ip protocol to apply firewall ingress rules to.
   # Defaults, appropriately, to 'tcp'.</diff>
      <filename>examples/capsize.yml.template</filename>
    </modified>
    <modified>
      <diff>@@ -103,12 +103,7 @@ module Capsize
 
       key_file = get_key_file(:key_name =&gt; options[:key_name], :key_dir =&gt; options[:key_dir])
 
-      # Verify keypair doesn't already exist on EC2 servers...
-      unless amazon.describe_keypairs(:key_name =&gt; options[:key_name]).keySet.nil?
-        raise Exception, &quot;Sorry, a keypair with the name \&quot;#{options[:key_name]}\&quot; already exists on EC2.&quot;
-      end
-
-      # and doesn't exist locally either...
+      # Verify local private key file doesn't already exist...
       file_exists_message = &lt;&lt;-MESSAGE
       \n
       Warning! A keypair with the name \&quot;#{key_file}\&quot;
@@ -118,8 +113,16 @@ module Capsize
       MESSAGE
       raise Exception, file_exists_message if File.exists?(key_file)
 
-      #All is good, so we create the new keypair
-      private_key = amazon.create_keypair(:key_name =&gt; options[:key_name])
+      # Try to create the new keypair
+      begin
+        private_key = amazon.create_keypair(:key_name =&gt; options[:key_name])
+      rescue EC2::InvalidKeyPairDuplicate
+        # keypair already exists with this :key_name
+        # Re-raising will provide a useful message, so we don't need to
+        raise
+      rescue EC2::InvalidKeyPairNotFound
+        # this is a new keypair, continue
+      end
 
       # write private key to file
       File.open(key_file, 'w') do |file|</diff>
      <filename>lib/capsize/ec2_plugin.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,9 +12,10 @@ Capistrano::Configuration.instance.load do
       - Create :capsize_secure_config_dir
       - Copy capsize.yml.template to :capsize_config_dir/capsize.yml unless it already exists
       - Automatically generate :capsize_secure_config_dir/secure.yml unless it already exists
-      - Instruct user to test configuration with &quot;cap ec2:images:describe&quot;
-      - Instruct user how to create a new keypair
-      - Instruct user how to setup a new security group.
+      - Automatically test authentication configuration with &quot;cap ec2:setup:check&quot;
+      - Automatically create a new keypair named by :key_name, or default to :application
+      - Automatically create a new security group named by :group_name, or default to :application
+      - Add ingress rules for this security group permitting global access on ports 22, 80 and 443
       DESC
       task :default do
 
@@ -28,7 +29,7 @@ Capistrano::Configuration.instance.load do
           FileUtils.mkdir fetch(:capsize_secure_config_dir)
         end
 
-        # copy the standard config file template, unless the dest file alread exists
+        # copy the standard config file template, unless the dest file already exists
         unless File.exists?(&quot;#{fetch(:capsize_secure_config_dir)}/#{fetch(:capsize_secure_config_file_name)}&quot;)
           puts &quot;Please enter your EC2 account information.&quot;
           puts &quot;We'll then write it to a config file at #{fetch(:capsize_secure_config_dir)}/#{fetch(:capsize_secure_config_file_name)}&quot;
@@ -117,7 +118,7 @@ EOF
           are likely most important).
 
           Now lets connect to it with SSH (this may take a few tries, sometimes it takes a
-          minute for the new instance to respond to SSH):
+          few minutes for the new instance to respond to SSH):
 
             cap ec2:instances:ssh INSTANCE_ID='i-xxxxxx'
 
@@ -149,8 +150,8 @@ EOF
 
       end
 
-    end
+    end # end namespace :setup
 
-  end
+  end # end namespace :ec2
 
 end</diff>
      <filename>lib/capsize/meta_tasks.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>44d1483968851ae42e275723ed528e84c6bf4cca</id>
    </parent>
  </parents>
  <author>
    <name>Ches Martin</name>
    <email>ches.martin@gmail.com</email>
  </author>
  <url>http://github.com/jnewland/capsize/commit/693b8644794d99848eabf00d0e34a6ced814ff6c</url>
  <id>693b8644794d99848eabf00d0e34a6ced814ff6c</id>
  <committed-date>2008-08-24T21:36:32-07:00</committed-date>
  <authored-date>2008-08-24T21:36:32-07:00</authored-date>
  <message>fix setup task (via create_keypair) and make descriptions more honest:
  * amazon-ec2 (now?) raises an exception when querying for a nonexistent key name, so handle that when creating a new keypair
  * other exception handling clean-up</message>
  <tree>68e90e6df837cf79621260010a35edf80d221ba8</tree>
  <committer>
    <name>Ches Martin</name>
    <email>ches.martin@gmail.com</email>
  </committer>
</commit>
