AppTower-ubistrano 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -50,13 +50,13 @@ set :ubistrano, {
50
50
  :repository => 'git@github.com:user/my-app.git',
51
51
 
52
52
  :production => {
53
- :domain => [ 'myapp.com', 'www.myapp.com' ],
54
- :host => '127.0.0.1'
53
+ :domains => [ 'myapp.com', 'www.myapp.com' ],
54
+ :host => '127.0.0.1'
55
55
  },
56
56
 
57
57
  :staging => {
58
- :domain => 'staging.myapp.com',
59
- :host => '127.0.0.1'
58
+ :domains => 'staging.myapp.com',
59
+ :host => '127.0.0.1'
60
60
  }
61
61
  }
62
62
 
data/Rakefile CHANGED
@@ -20,4 +20,12 @@ file 'ubistrano.gemspec' => FileList['{example,lib,templates}/**','Rakefile'] do
20
20
  spec = parts.join(" # = MANIFEST =\n")
21
21
  File.open(f.name, 'w') { |io| io.write(spec) }
22
22
  puts "Updated #{f.name}"
23
+ end
24
+
25
+ # sudo rake install
26
+ task :install do
27
+ `gem uninstall ubistrano`
28
+ `gem build ubistrano.gemspec`
29
+ `gem install ubistrano*.gem`
30
+ `rm ubistrano*.gem`
23
31
  end
data/changelog.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ Version 1.2.0
2
+ -------------
3
+
4
+ * New EC2 tasks
5
+ * EC2 setup and `cap ubuntu` provision tested
6
+
1
7
  Version 1.1.0
2
8
  -------------
3
9
 
data/example/deploy.rb CHANGED
@@ -1,17 +1,20 @@
1
1
  set :ubistrano, {
2
- :application => :my_app,
3
- :platform => :rails, # :php, :rails, :sinatra
4
- :repository => 'git@github.com:user/my-app.git',
2
+ :application => :my_app,
3
+ :platform => :rails, # :php, :rails, :sinatra
4
+ :repository => 'git@github.com:user/my-app.git',
5
+
6
+ :ec2 => {
7
+ :access_key => '',
8
+ :secret_key => ''
9
+ },
5
10
 
6
11
  :production => {
7
- :domain => [ 'myapp.com', 'www.myapp.com' ],
8
- :host => '127.0.0.1'
12
+ :domains => [ 'myapp.com', 'www.myapp.com' ],
13
+ :host => '127.0.0.1'
9
14
  },
10
15
 
11
16
  :staging => {
12
- :domain => 'staging.myapp.com',
13
- :host => '127.0.0.1'
17
+ :domains => [ 'staging.myapp.com' ],
18
+ :host => '127.0.0.1'
14
19
  }
15
- }
16
-
17
- require 'ubistrano'
20
+ }
data/lib/ubistrano.rb CHANGED
@@ -1,4 +1,7 @@
1
1
 
2
+ require 'EC2'
3
+ require 'pp'
4
+
2
5
  # Require helpers and recipes
3
6
  Dir["#{File.dirname(__FILE__)}/ubistrano/*.rb"].each { |f| require f }
4
7
 
@@ -11,7 +14,7 @@ Capistrano::Configuration.instance(:must_exist).load do
11
14
  :db_user => 'app',
12
15
  :db_pass => '',
13
16
  :deploy_via => :remote_cache,
14
- :domain => [],
17
+ :domains => [],
15
18
  :platform => :rails,
16
19
  :plugins => {},
17
20
  :port => 22,
@@ -0,0 +1,111 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :ec2 do
4
+ desc "Set up your machine to use EC2"
5
+ task :default, :roles => :web do
6
+ ec2.key_pair.install
7
+ end
8
+
9
+ namespace :instance do
10
+ desc "Create a fresh Hardy instance"
11
+ task :create do
12
+ options = {
13
+ :image_id => ask('Press enter for Ubuntu Hardy or enter an AMI image id: ', 'ami-1c5db975'),
14
+ :key_name => "#{application}"
15
+ }
16
+ instance = ec2_api.run_instances(options).instancesSet.item[0]
17
+ instance_id = instance.instanceId
18
+ pp instance
19
+ ip = ec2_api.allocate_address.publicIp
20
+ ec2_api.associate_address(:instance_id => instance_id, :public_ip => ip)
21
+ puts "Your instance id is: #{instance_id}"
22
+ puts "Your IP address is: #{ip}"
23
+ end
24
+
25
+ desc "Restart an instance"
26
+ task :restart do
27
+ ec2.instances
28
+ pp ec2_api.reboot_instances(:instance_id => ask("Restart which instance ids?"))
29
+ end
30
+
31
+ desc "Destroy an instance"
32
+ task :destroy do
33
+ ec2.instances
34
+ instance_id = ask("Terminate which instance ids?")
35
+ ec2_api.terminate_instances(:instance_id => instance_id)
36
+ ip = ec2_api.describe_addresses.addressesSet.item.select { |x| x.instanceId == instance_id }.first
37
+ ec2_api.release_address(:public_ip => ip.publicIp) if ip
38
+ end
39
+ end
40
+
41
+ desc "List your EC2 instances"
42
+ task :instances do
43
+ pp ec2_api.describe_instances
44
+ end
45
+
46
+ desc "List IPs for this EC2 account"
47
+ task :ips do
48
+ pp ec2_api.describe_addresses
49
+ end
50
+
51
+ namespace :key_pair do
52
+ desc "Install key pair for SSH"
53
+ task :install do
54
+ begin
55
+ out = ec2_api.create_keypair(:key_name => application.to_s)
56
+ pp out
57
+ key = out.keyMaterial
58
+ rescue EC2::InvalidKeyPairDuplicate
59
+ ec2.key_pair.remove
60
+ ec2.key_pair.install
61
+ end
62
+ File.open(File.expand_path("~/.ssh/id_rsa-#{application}"), 'w') { |f| f.write key }
63
+ "chmod 600 ~/.ssh/id_rsa-#{application}"
64
+ end
65
+
66
+ desc "Install key pair for SSH"
67
+ task :remove do
68
+ ec2_api.delete_keypair(:key_name => application.to_s)
69
+ `rm ~/.ssh/id_rsa-#{application}`
70
+ end
71
+ end
72
+
73
+ namespace :security do
74
+ namespace :group do
75
+ desc "Open standard ports for default security group"
76
+ task :create do
77
+ [ 22, 80 ].each do |port|
78
+ ec2_api.authorize_security_group_ingress(
79
+ :group_name => 'default', :cidr_ip => '0.0.0.0/0', :from_port => port, :to_port => port, :ip_protocol => 'tcp'
80
+ )
81
+ end
82
+ end
83
+
84
+ desc "Describe default security group"
85
+ task :describe do
86
+ pp ec2_api.describe_security_groups(:group_name => 'default')
87
+ end
88
+ end
89
+ end
90
+
91
+ namespace :api_tools do
92
+ desc "Install ec2 api tools locally"
93
+ task :install, :roles => :web do
94
+ `cd ~ && curl http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip -O`
95
+ `cd ~ && unzip ec2-api-tools.zip`
96
+ `cd ~ && rm ec2-api-tools.zip`
97
+ `mv ~/ec2-api-tools-* ~/.ec2`
98
+ end
99
+
100
+ desc "Install ec2 api tools locally"
101
+ task :remove, :roles => :web do
102
+ `rm -Rf ~/.ec2`
103
+ end
104
+ end
105
+
106
+ def ec2_api
107
+ @ec2_api ||= EC2::Base.new(:access_key_id => ec2_access_key, :secret_access_key => ec2_secret_key)
108
+ end
109
+ end
110
+
111
+ end
@@ -18,13 +18,12 @@ Capistrano::Configuration.instance(:must_exist).load do
18
18
  set :db_table, "#{application}#{stage == :staging ? "_#{stage}" : ''}"
19
19
 
20
20
  ubistrano[stage].each do |key, value|
21
- value = [ value ].flatten if key == :domain
22
21
  set key, value
23
22
  end
24
23
 
25
24
  role :app, host, :primary => true
26
- role :web, host
27
- role :db, host
25
+ role :web, host, :primary => true
26
+ role :db, host, :primary => true
28
27
  end
29
28
 
30
29
  end
@@ -223,7 +223,7 @@ Capistrano::Configuration.instance(:must_exist).load do
223
223
  if yes("May I install Passenger (mod_rails)?")
224
224
  sudo_puts 'aptitude install apache2-prefork-dev -q -y'
225
225
  gem_install :passenger
226
- apache.reload if yes(msg(:passenger))
226
+ ROOT.apache.reload if yes(msg(:passenger))
227
227
  end
228
228
  end
229
229
 
@@ -1,7 +1,7 @@
1
1
  <VirtualHost *:80>
2
- <% unless domain.empty? %>
3
- ServerName <%= domain.first %>
4
- ServerAlias <%= domain[1..-1].join ' ' %>
2
+ <% unless domains.empty? %>
3
+ ServerName <%= domains.first %>
4
+ ServerAlias <%= domains[1..-1].join ' ' %>
5
5
  <% end %>
6
6
  DocumentRoot <%= deploy_to %>/current/public
7
7
  </VirtualHost>
data/ubistrano.gemspec CHANGED
@@ -1,16 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ubistrano'
3
- s.version = '1.1.0'
4
- s.date = '2008-12-14'
3
+ s.version = '1.2.1'
4
+ s.date = '2008-01-20'
5
5
 
6
6
  s.summary = "Provision and deploy to an Ubuntu/God/Apache/Passenger stack using Capistrano"
7
7
  s.description = "Provision and deploy to an Ubuntu/God/Apache/Passenger stack using Capistrano"
8
8
 
9
- s.author = 'AppTower'
10
- s.email = 'apptower@wintoni.us'
9
+ s.author = 'Winton Welsh'
10
+ s.email = 'mail@wintoni.us'
11
11
  s.homepage = 'http://github.com/AppTower/ubistrano'
12
12
 
13
13
  s.has_rdoc = false
14
+ s.add_dependency 'amazon-ec2', '>= 0.3.2'
14
15
 
15
16
  # = MANIFEST =
16
17
  s.files = %w[
@@ -22,6 +23,7 @@ Gem::Specification.new do |s|
22
23
  lib/ubistrano.rb
23
24
  lib/ubistrano/apache.rb
24
25
  lib/ubistrano/deploy.rb
26
+ lib/ubistrano/ec2.rb
25
27
  lib/ubistrano/gems.rb
26
28
  lib/ubistrano/helpers.rb
27
29
  lib/ubistrano/log.rb
metadata CHANGED
@@ -1,20 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: AppTower-ubistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
- - AppTower
7
+ - Winton Welsh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-14 00:00:00 -08:00
12
+ date: 2008-01-20 00:00:00 -08:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: amazon-ec2
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.2
23
+ version:
16
24
  description: Provision and deploy to an Ubuntu/God/Apache/Passenger stack using Capistrano
17
- email: apptower@wintoni.us
25
+ email: mail@wintoni.us
18
26
  executables: []
19
27
 
20
28
  extensions: []
@@ -30,6 +38,7 @@ files:
30
38
  - lib/ubistrano.rb
31
39
  - lib/ubistrano/apache.rb
32
40
  - lib/ubistrano/deploy.rb
41
+ - lib/ubistrano/ec2.rb
33
42
  - lib/ubistrano/gems.rb
34
43
  - lib/ubistrano/helpers.rb
35
44
  - lib/ubistrano/log.rb