dew 0.1.5 → 0.1.6

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/bin/dew CHANGED
@@ -2,10 +2,10 @@
2
2
  require 'dew'
3
3
 
4
4
  class DewCommand < DewBaseCommand
5
- option ['-r', '--region'], "REGION", "AWS region", :default => 'ap-southeast-1'
6
- option ['-a', '--account'], "ACCOUNT", "AWS account", :default => 'development'
5
+ option ['-r', '--region'], "REGION", "AWS region", :default => ENV['DEW_REGION'] || 'ap-southeast-1'
6
+ option ['-a', '--account'], "ACCOUNT", "AWS account", :default => ENV['DEW_ACCOUNT'] || 'development'
7
7
  option ['-q', '--quiet'], :flag, "Quiet mode, disables logging", :default => false
8
- option ['-v', '--verbose'], :flag, "Verbose mode, print debug output", :default => false
8
+ option ['-v', '--verbose'], :flag, "Verbose mode, print debug output", :default => ENV['DEW_VERBOSE']
9
9
  option '--debug', :flag, "Show stacktraces on error", :default => false
10
10
  option '--version', :flag, "Prints the dew version" do
11
11
  puts "dew version #{Dew::VERSION}"
data/config/cucumber.yaml CHANGED
@@ -1,4 +1,4 @@
1
- default: features -t~@wip -t~@slow
2
- slow: features -t~@wip -t@slow
3
- wip: features -t@wip
4
- all: features -t~@wip
1
+ default: features -t~@wip -t~@slow -t~@disabled
2
+ slow: features -t~@wip -t@slow -t~@disabled
3
+ wip: features -t@wip -t~@disabled
4
+ all: features -t~@wip -t~@disabled
@@ -6,6 +6,7 @@ Feature: Creating a new AMI
6
6
 
7
7
  @aws
8
8
  @slow
9
+ @disabled
9
10
  Scenario: Creating a new AMI from a puppet configuration
10
11
  Given I specify the puppet configuration "blank"
11
12
  And I uniquely name my AMI
data/lib/dew.rb CHANGED
@@ -1,5 +1,8 @@
1
+ require 'clamp'
2
+ require 'gofer'
1
3
  require 'inform'
2
4
  require 'highline/import'
5
+ require 'opensrs'
3
6
  require 'dew/version'
4
7
  require 'dew/commands'
5
8
  require 'dew/models'
@@ -7,3 +10,5 @@ require 'dew/controllers'
7
10
  require 'dew/cloud'
8
11
  require 'dew/view'
9
12
  require 'dew/password'
13
+ require 'fog' # require fog last - slows down all other require calls
14
+
@@ -1,5 +1,3 @@
1
- require 'clamp'
2
-
3
1
  # Monkey patch clamp to remove duplicate options from help
4
2
  module Clamp::Option::Declaration
5
3
  alias_method :non_uniq_documented_options, :documented_options
data/lib/dew/cloud.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'opensrs'
1
+ # require 'opensrs'
2
2
 
3
3
  class Cloud
4
4
 
@@ -72,7 +72,7 @@ class Cloud
72
72
  end
73
73
 
74
74
  def dns
75
- @dns ||= OpenSRS::Server.new(account.opensrs_credentials)
75
+ # @dns ||= OpenSRS::Server.new(account.opensrs_credentials)
76
76
  end
77
77
 
78
78
  private
@@ -52,12 +52,20 @@ class DeployCommand < Clamp::Command
52
52
  env.remove_server_from_elb(server) if env.has_elb?
53
53
 
54
54
  @ssh = server.ssh
55
+ is_redhat = ssh.exist?('/etc/redhat-release')
56
+ if is_redhat
57
+ Inform.info("RedHat server detected")
58
+ end
55
59
  initial = !ssh.exist?(application_name)
56
60
 
57
61
  Inform.info("%{app} doesn't exist - initial install", :app => application_name) if initial
58
62
 
59
63
  Inform.info("Stopping apache") do
60
- ssh.run "sudo apache2ctl stop"
64
+ if is_redhat
65
+ ssh.run "sudo /etc/init.d/httpd stop"
66
+ else
67
+ ssh.run "sudo apache2ctl stop"
68
+ end
61
69
  end
62
70
 
63
71
  Inform.info("Obtaining version %{v} of %{app}", :v => revision, :app => application_name) do
@@ -70,17 +78,20 @@ class DeployCommand < Clamp::Command
70
78
  ssh.run "git clone git@github.com:playup/#{application_name}.git #{application_name}"
71
79
  else
72
80
  Inform.debug("Updating %{app} repository", :app => application_name)
73
- check_and_remove_rvmrc
81
+ check_and_remove_rvmrc unless is_redhat
74
82
  ssh.run "cd #{application_name}; git fetch -q"
75
83
  end
76
84
 
77
- check_and_remove_rvmrc
85
+ check_and_remove_rvmrc unless is_redhat
78
86
  Inform.debug("Checking out version %{version}", :version => revision)
79
87
  ssh.run "cd #{application_name} && git checkout -q -f #{revision}"
80
- check_and_remove_rvmrc
88
+ check_and_remove_rvmrc unless is_redhat
81
89
  end
82
-
90
+
83
91
  cd_and_rvm = "cd #{application_name} && . /usr/local/rvm/scripts/rvm && rvm use ruby-1.9.2 && RAILS_ENV=#{rails_env} "
92
+ if is_redhat
93
+ cd_and_rvm = "cd #{application_name} && RAILS_ENV=#{rails_env} "
94
+ end
84
95
 
85
96
  Inform.info("Updating/installing gems") do
86
97
  ssh.run cd_and_rvm + "bundle install --without development"
@@ -109,7 +120,11 @@ class DeployCommand < Clamp::Command
109
120
  end
110
121
  end
111
122
 
123
+
112
124
  if use_ssl?
125
+ if is_redhat
126
+ raise "SSL not yet supported for redhat"
127
+ end
113
128
  Inform.info "Enabling Mod SSL" do
114
129
  ssh.run "sudo a2enmod ssl"
115
130
  end
@@ -123,6 +138,9 @@ class DeployCommand < Clamp::Command
123
138
  end
124
139
 
125
140
  if gamej_proxy
141
+ if is_redhat
142
+ raise "gamej proxy not yet supported for redhat"
143
+ end
126
144
  Inform.info "Enabling Mod Proxy" do
127
145
  ssh.run "sudo a2enmod proxy"
128
146
  ssh.run "sudo a2enmod proxy_http"
@@ -130,6 +148,7 @@ class DeployCommand < Clamp::Command
130
148
  end
131
149
 
132
150
  Inform.info("Starting application") do
151
+ conf_dest = is_redhat ? "/etc/httpd/conf.d/#{application_name}.conf" : "/etc/apache2/sites-available/#{application_name}"
133
152
  if ssh.exist?('/etc/apache2/sites-enabled/000-default')
134
153
  Inform.debug("Disabling default apache site")
135
154
  ssh.run "sudo a2dissite default"
@@ -140,19 +159,24 @@ class DeployCommand < Clamp::Command
140
159
  :use_ssl? => use_ssl?,
141
160
  :server_name => server_name,
142
161
  :rails_env => rails_env,
162
+ :log_dir => is_redhat ? '/var/log/httpd' : '/var/log/apache2',
143
163
  :application_name => application_name,
144
164
  :working_directory => "/home/ubuntu/#{application_name}",
145
165
  :gamej_proxy => gamej_proxy
146
166
  ).instance_eval {binding})
147
167
  ssh.write passenger_config, "/tmp/apache.conf"
148
- ssh.run "sudo cp /tmp/apache.conf /etc/apache2/sites-available/#{application_name}"
149
- ssh.run "sudo chmod 0644 /etc/apache2/sites-available/#{application_name}" # yeah, I don't know why it gets written as 0600
150
- unless ssh.exist?('/etc/apache2/sites-enabled/#{application_name}')
168
+ ssh.run "sudo cp /tmp/apache.conf #{conf_dest}"
169
+ ssh.run "sudo chmod 0644 #{conf_dest}" # yeah, I don't know why it gets written as 0600
170
+ unless is_redhat || ssh.exist?('/etc/apache2/sites-enabled/#{application_name}')
151
171
  Inform.debug("Enabling site in apache")
152
172
  ssh.run "sudo a2ensite #{application_name}"
153
173
  end
154
174
  Inform.debug("Restarting apache")
155
- ssh.run "sudo apache2ctl restart"
175
+ if is_redhat
176
+ ssh.run "sudo /etc/init.d/httpd start"
177
+ else
178
+ ssh.run "sudo apache2ctl start"
179
+ end
156
180
  end
157
181
 
158
182
  unless server_name || !use_passenger?
@@ -28,13 +28,13 @@
28
28
  AddType text/x-component .htc
29
29
  </Directory>
30
30
 
31
- ErrorLog /var/log/apache2/<%= application_name %>-error.log
31
+ ErrorLog <%= log_dir %>/<%= application_name %>-error.log
32
32
 
33
33
  # Possible values include: debug, info, notice, warn, error, crit,
34
34
  # alert, emerg.
35
35
  LogLevel warn
36
36
 
37
- CustomLog /var/log/apache2/<%= application_name %>-access.log combined
37
+ CustomLog <%= log_dir %>/<%= application_name %>-access.log combined
38
38
 
39
39
  <% if gamej_proxy %>
40
40
  <Location /api>
data/lib/dew/models.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'fog'
2
1
  require 'dew/models/account'
3
2
  require 'dew/models/fog_model'
4
3
  require 'dew/models/deploy'
@@ -27,23 +27,15 @@ class Account
27
27
  def has_dns?
28
28
  @yaml.include?('dns')
29
29
  end
30
-
31
- def dns_username
32
- @yaml['dns']['username']
33
- end
34
-
35
- def dns_password
36
- @yaml['dns']['password']
30
+
31
+ def dns_key
32
+ @yaml['dns']['key']
37
33
  end
38
34
 
39
35
  def dns_domain
40
36
  @yaml['dns']['domain']
41
37
  end
42
38
 
43
- def dns_prefix
44
- @yaml['dns']['prefix']
45
- end
46
-
47
39
  def initialize(yaml)
48
40
  @yaml = yaml
49
41
  end
@@ -1,5 +1,3 @@
1
- require 'gofer'
2
-
3
1
  class Server < FogModel
4
2
  TEN_SECONDS = 10
5
3
  SIXTY_SECONDS = 60
data/lib/dew/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dew
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -95,9 +95,10 @@ describe :Cloud do
95
95
  it { Cloud.has_dns?.should be_true }
96
96
 
97
97
  it "should provide an OpenSRS DNS handle" do
98
- Cloud.account.should_receive(:opensrs_credentials).and_return('opensrs creds')
99
- OpenSRS::Server.should_receive(:new).with('opensrs creds').and_return('server')
100
- Cloud.dns.should == 'server'
98
+ pending
99
+ # Cloud.account.should_receive(:opensrs_credentials).and_return('opensrs creds')
100
+ # OpenSRS::Server.should_receive(:new).with('opensrs creds').and_return('server')
101
+ # Cloud.dns.should == 'server'
101
102
  end
102
103
  end
103
104
  end
@@ -38,17 +38,13 @@ describe Account do
38
38
  let (:yaml) {
39
39
  "
40
40
  dns:
41
- username: bob
42
41
  domain: mydomain.com
43
- password: steve
44
- prefix: env
42
+ key: a1b2c3d4e5
45
43
  "
46
44
  }
47
45
  it { subject.has_dns?.should be_true }
48
- it { subject.dns_username.should == 'bob' }
46
+ it { subject.dns_key.should == 'a1b2c3d4e5' }
49
47
  it { subject.dns_domain.should == 'mydomain.com' }
50
- it { subject.dns_password.should == 'steve' }
51
- it { subject.dns_prefix.should == 'env' }
52
48
  end
53
49
  end
54
50
 
@@ -5,7 +5,7 @@ describe Deploy::Puge do
5
5
  let (:tag) { 'puge-1.16.1' }
6
6
  let (:rails_env) { 'development' }
7
7
  let (:gofer) { double('Gofer').as_null_object }
8
- let (:servers) { (0..1).map { |i| double("Server #{i}").as_null_object} }
8
+ let (:servers) { (0..1).map { |i| double("Server #{i}", :id => nil).as_null_object} }
9
9
  let (:environment) {double('Environment', :servers => servers, :database => database)}
10
10
  let (:opts) { { 'tag' => tag, 'rails_env' => rails_env } }
11
11
  let (:run_on_servers) { servers }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dew
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.5
5
+ version: 0.1.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - PlayUp Devops
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-07 00:00:00 +10:00
14
- default_executable:
13
+ date: 2011-07-13 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: inform
@@ -244,7 +243,6 @@ files:
244
243
  - features/support/hooks.rb
245
244
  - config/cucumber.yaml
246
245
  - bin/dew
247
- has_rdoc: true
248
246
  homepage: http://github.com/playup/dew
249
247
  licenses: []
250
248
 
@@ -268,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
266
  requirements: []
269
267
 
270
268
  rubyforge_project:
271
- rubygems_version: 1.6.2
269
+ rubygems_version: 1.8.3
272
270
  signing_key:
273
271
  specification_version: 3
274
272
  summary: Uses fog to access the cloud