rubber 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30a59a4d64e36a68db212a6981a372bca1c068dd
4
- data.tar.gz: 7ceb0e3669077e1c233cfe4591070138bf34950f
3
+ metadata.gz: d4a86ae39c4c054ff5a2ee091be683d011eca4b9
4
+ data.tar.gz: 2eb0ad4e985ed83c0937a682955e4498d99140c6
5
5
  SHA512:
6
- metadata.gz: 16199697b6e470ef26c5408a628abee2ac085fb72db8ce240d37b544aae62d32923988b188d292472cf38e141392c181eaa29f479c16d9b77e4eb551cbb1668d
7
- data.tar.gz: 74e1de3912d38cb50150d6c80d40e4c82ad3f66423c70770b424b75de7bbdde5a40e9e76eb81a403c162826b2312ccdca113a8011b3f6af72d378b6d24475f37
6
+ metadata.gz: ddf6ae11d0479fb544f4e9c093839503ab3ddd1d3f75057e207ab4612cfbe1002c33d354961b6fcddb32689f9c5a3dc2c327cc1ec10e9f85cfa04ddf28f4beb1
7
+ data.tar.gz: 671bda85dea0936d593772f405ec5536fc841a2cb9fa217f85553ce3221ae3448dd0eb382f96ec66890b7281b14c74e85af30278f90254266ce4e29931464455
data/CHANGELOG CHANGED
@@ -1,3 +1,24 @@
1
+ 2.15.0 (10/24/2014)
2
+
3
+ New Features:
4
+ ============
5
+
6
+ [core] Add the ability to pass custom fog specific options during instance and volume creation. <a2e1c67>
7
+
8
+ Improvements:
9
+ ============
10
+
11
+ [base] Document private networking support for new Digital Ocean regions: New York 3 and Amsterdam 3. <e85360f>
12
+ [base] Switch from ext3 to ext4 as the example filesystem in volume creation. <a21b95d>
13
+
14
+ Bug Fixes:
15
+ =========
16
+
17
+ [nginx] Add Nginx parameter required by DigitalOcean droplets. <24ac1aa>
18
+ [postgresql] Surround postgresql database name with quotes to avoid syntax error when using dash. <4017979>
19
+
20
+
21
+
1
22
  2.14.0 (10/13/2014)
2
23
 
3
24
  Improvements:
@@ -320,7 +320,11 @@ module Rubber
320
320
  end
321
321
 
322
322
  def create_volume(instance, volume_spec)
323
- volume = compute_provider.volumes.create(:size => volume_spec['size'], :availability_zone => volume_spec['zone'])
323
+ fog_options = Rubber::Util.symbolize_keys(volume_spec['fog_options'] || {})
324
+ volume_data = {
325
+ :size => volume_spec['size'], :availability_zone => volume_spec['zone']
326
+ }.merge(fog_options)
327
+ volume = compute_provider.volumes.create(volume_data)
324
328
  volume.id
325
329
  end
326
330
 
@@ -29,11 +29,11 @@ module Rubber
29
29
  super(env, capistrano)
30
30
  end
31
31
 
32
- # As of July 2014 Digital Ocean supports private networking in
33
- # New York 2 (id 4), Amsterdam 2 (id 5), Singapore 1 (id 6) and London 1 (id 7)
34
- REGIONS_WITH_PRIVATE_NETWORKING = [4, 5, 6, 7]
32
+ # As of October 2014 Digital Ocean supports private networking in
33
+ # New York 2 (id 4), New York 3 (id 8), Amsterdam 2 (id 5), Amsterdam 3 (id 9), Singapore 1 (id 6) and London 1 (id 7)
34
+ REGIONS_WITH_PRIVATE_NETWORKING = [4, 5, 6, 7, 8, 9]
35
35
 
36
- def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, region)
36
+ def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, region, fog_options={})
37
37
  do_region = compute_provider.regions.find { |r| r.name == region }
38
38
  if do_region.nil?
39
39
  raise "Invalid region for DigitalOcean: #{region}"
@@ -64,12 +64,14 @@ module Rubber
64
64
  end
65
65
  end
66
66
 
67
- response = compute_provider.servers.create(:name => "#{Rubber.env}-#{instance_alias}",
67
+ response = compute_provider.servers.create({:name => "#{Rubber.env}-#{instance_alias}",
68
68
  :image_id => image.id,
69
69
  :flavor_id => flavor.id,
70
70
  :region_id => do_region.id,
71
71
  :ssh_key_ids => [ssh_key['id']],
72
- :private_networking => (env.private_networking.to_s.downcase == 'true'))
72
+ :private_networking => (env.private_networking.to_s.downcase == 'true')}.
73
+ merge(Rubber::Util.symbolize_keys(fog_options))
74
+ )
73
75
 
74
76
  response.id
75
77
  end
@@ -29,13 +29,15 @@ module Rubber
29
29
  raise NotImplementedError, "No table store available for generic fog adapter"
30
30
  end
31
31
 
32
- def create_instance(instance_alias, ami, ami_type, security_groups, availability_zone, region)
33
- response = compute_provider.servers.create(:image_id => ami,
32
+ def create_instance(instance_alias, ami, ami_type, security_groups, availability_zone, region, fog_options={})
33
+
34
+ response = compute_provider.servers.create({:image_id => ami,
34
35
  :flavor_id => ami_type,
35
36
  :groups => security_groups,
36
37
  :availability_zone => availability_zone,
37
38
  :key_name => env.key_name,
38
- :name => instance_alias)
39
+ :name => instance_alias}.merge(
40
+ Rubber::Util.symbolize_keys(fog_options)))
39
41
 
40
42
  response.id
41
43
  end
@@ -26,7 +26,7 @@ module Rubber
26
26
  'active'
27
27
  end
28
28
 
29
- def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, region)
29
+ def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, region, fog_options={})
30
30
  instance = {}
31
31
  instance[:id] = instance_alias
32
32
  instance[:state] = active_state
@@ -35,7 +35,7 @@ module Rubber
35
35
  instance[:provider] = 'generic'
36
36
  instance[:platform] = Rubber::Platforms::LINUX
37
37
 
38
- Generic.add_instance(instance)
38
+ Generic.add_instance(instance.merge(Rubber::Util.symbolize_keys(fog_options)))
39
39
 
40
40
  instance_alias
41
41
  end
@@ -29,7 +29,7 @@ module Rubber
29
29
  super(env, capistrano)
30
30
  end
31
31
 
32
- def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, datacenter)
32
+ def create_instance(instance_alias, image_name, image_type, security_groups, availability_zone, datacenter, fog_options={})
33
33
  if env.domain.nil?
34
34
  raise "'domain' value must be configured"
35
35
  end
@@ -199,7 +199,8 @@ module Rubber
199
199
  config[:eager_zero] = eager_zero
200
200
  end
201
201
 
202
- volume = server.volumes.create(config)
202
+ fog_options = Rubber::Util.symbolize_keys(volume_spec['fog_options'] || {})
203
+ volume = server.volumes.create(config.merge(fog_options))
203
204
 
204
205
  volume.id
205
206
  end
@@ -274,6 +274,7 @@ namespace :rubber do
274
274
  ami_type = cloud_env.image_type
275
275
  availability_zone = cloud_env.availability_zone
276
276
  region = cloud_env.region
277
+ fog_options = cloud_env.fog_options || {}
277
278
 
278
279
  create_spot_instance ||= cloud_env.spot_instance
279
280
 
@@ -281,7 +282,7 @@ namespace :rubber do
281
282
  spot_price = cloud_env.spot_price.to_s
282
283
 
283
284
  logger.info "Creating spot instance request for instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || 'Default'}"
284
- request_id = cloud.create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone)
285
+ request_id = cloud.create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone, fog_options)
285
286
 
286
287
  print "Waiting for spot instance request to be fulfilled"
287
288
  max_wait_time = cloud_env.spot_instance_request_timeout || (1.0 / 0) # Use the specified timeout value or default to infinite.
@@ -308,7 +309,7 @@ namespace :rubber do
308
309
 
309
310
  if !create_spot_instance || (create_spot_instance && max_wait_time < 0)
310
311
  logger.info "Creating instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || region || 'Default'}"
311
- instance_id = cloud.create_instance(instance_alias, ami, ami_type, security_groups, availability_zone, region)
312
+ instance_id = cloud.create_instance(instance_alias, ami, ami_type, security_groups, availability_zone, region, fog_options)
312
313
  end
313
314
 
314
315
  logger.info "Instance #{instance_alias} created: #{instance_id}"
@@ -1,3 +1,3 @@
1
1
  module Rubber
2
- VERSION = '2.14.0'.freeze
2
+ VERSION = '2.15.0'.freeze
3
3
  end
@@ -89,6 +89,17 @@ cloud_providers:
89
89
  image_type: c1.medium
90
90
  image_id: ami-90c574f8
91
91
 
92
+ # OPTIONAL: Provide fog-specific options directly. This should only be used if you need a special setting that
93
+ # Rubber does not directly expose. Since these settings will be passed directly through to fog, we can't make any
94
+ # guarantee about how they work (if fog renames an attribute, e.g., your config will break). Please see the fog
95
+ # source code for the option names.
96
+ # fog_options:
97
+ # EBS I/O optimized instance
98
+ # EBS-optimized instances deliver dedicated throughput between Amazon EC2 and Amazon EBS, with options
99
+ # between 500 Mbps and 1000 Mbps depending on the instance type used.
100
+ # Read more and make sure that your image_type supports ebs_optimized function at: http://aws.amazon.com/ec2/instance-types/
101
+ # ebs_optimized: false
102
+
92
103
  # OPTIONAL: EC2 spot instance request support.
93
104
  #
94
105
  # Enables the creation of spot instance requests. Rubber will wait synchronously until the request is fulfilled,
@@ -324,21 +335,39 @@ staging_roles: "#{known_roles.reject {|r| r =~ /slave/ || r =~ /^db$/ }.join(','
324
335
  # zone: us-east-1a # zone to create volume in, needs to match host's zone
325
336
  # device: /dev/sdh # OS device to attach volume to
326
337
  # mount: /mnt/mysql # The directory to mount this volume to
327
- # filesystem: ext3 # the filesystem to create on volume
328
- # - size: 10 # size of vol in GBs
329
- # zone: us-east-1a # zone to create volume in, needs to match host's zone
330
- # device: /dev/sdi # OS device to attach volume to
331
- # mount: /mnt/logs # The directory to mount this volume to
332
- # filesystem: ext3 # the filesystem to create on volume
338
+ # filesystem: ext4 # the filesystem to create on volume
339
+ #
340
+ # # OPTIONAL: Provide fog-specific options directly. This should only be used if you need a special setting that
341
+ # # Rubber does not directly expose. Since these settings will be passed directly through to fog, we can't make any
342
+ # # guarantee about how they work (if fog renames an attribute, e.g., your config will break). Please see the fog
343
+ # # source code for the option names.
344
+ # fog_options:
345
+ # type: standard # type of volume, standard or io1
346
+ # iops: 500 # The number of I/O operations per second (IOPS) that the volume supports.
347
+ # # Required when the volume type is io1; not used with standard volumes.
348
+ # - size: 10
349
+ # zone: us-east-1a
350
+ # device: /dev/sdi
351
+ # mount: /mnt/logs
352
+ # filesystem: ext4
353
+ # fog_options:
354
+ # type: standard
355
+ # iops: 500
333
356
  #
334
357
  # # volumes without mount/filesystem can be used in raid arrays
335
358
  #
336
- # - size: 50 # size of vol in GBs
337
- # zone: us-east-1a # zone to create volume in, needs to match host's zone
338
- # device: /dev/sdx # OS device to attach volume to
339
- # - size: 50 # size of vol in GBs
340
- # zone: us-east-1a # zone to create volume in, needs to match host's zone
341
- # device: /dev/sdy # OS device to attach volume to
359
+ # - size: 50
360
+ # zone: us-east-1a
361
+ # device: /dev/sdx
362
+ # fog_options:
363
+ # type: gp2
364
+ # iops: 500
365
+ # - size: 50
366
+ # zone: us-east-1a
367
+ # device: /dev/sdy
368
+ # fog_options:
369
+ # type: gp2
370
+ # iops: 500
342
371
  #
343
372
  # # Use some ephemeral volumes for raid array
344
373
  # local_volumes:
@@ -21,6 +21,7 @@ http
21
21
  sendfile on;
22
22
  tcp_nopush on;
23
23
  tcp_nodelay off;
24
+ types_hash_max_size 2048;
24
25
 
25
26
  gzip on;
26
27
  gzip_http_version 1.0;
@@ -1,7 +1,7 @@
1
1
  namespace :rubber do
2
-
2
+
3
3
  namespace :postgresql do
4
-
4
+
5
5
  rubber.allow_optional_tasks(self)
6
6
 
7
7
  before "rubber:install_packages", "rubber:postgresql:setup_apt_sources"
@@ -12,7 +12,7 @@ namespace :rubber do
12
12
  wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
13
13
  ENDSCRIPT
14
14
  end
15
-
15
+
16
16
  after "rubber:create", "rubber:postgresql:validate_db_roles"
17
17
 
18
18
  task :validate_db_roles do
@@ -25,16 +25,16 @@ namespace :rubber do
25
25
  end
26
26
 
27
27
  after "rubber:bootstrap", "rubber:postgresql:bootstrap"
28
-
28
+
29
29
  # Bootstrap the production database config. Db bootstrap is special - the
30
30
  # user could be requiring the rails env inside some of their config
31
31
  # templates, which creates a catch 22 situation with the db, so we try and
32
32
  # bootstrap the db separate from the rest of the config
33
33
  task :bootstrap, :roles => [:postgresql_master, :postgresql_slave] do
34
-
34
+
35
35
  # Conditionally bootstrap for each node/role only if that node has not
36
36
  # been bootstrapped for that role before
37
- master_instances = rubber_instances.for_role("postgresql_master") & rubber_instances.filtered
37
+ master_instances = rubber_instances.for_role("postgresql_master") & rubber_instances.filtered
38
38
  master_instances.each do |ic|
39
39
  task_name = "_bootstrap_postgresql_master_#{ic.full_name}".to_sym
40
40
  task task_name, :hosts => ic.full_name do
@@ -55,7 +55,7 @@ namespace :rubber do
55
55
  rubber.sudo_script "create_master_db", <<-ENDSCRIPT
56
56
  sudo -i -u postgres psql -c "#{create_user_cmd}"
57
57
  sudo -i -u postgres psql -c "#{create_replication_user_cmd}"
58
- sudo -i -u postgres psql -c "CREATE DATABASE #{env.db_name} WITH OWNER #{env.db_user}"
58
+ sudo -i -u postgres psql -c "CREATE DATABASE \"#{env.db_name}\" WITH OWNER #{env.db_user}"
59
59
  ENDSCRIPT
60
60
  end
61
61
  end
@@ -91,7 +91,7 @@ namespace :rubber do
91
91
  def common_bootstrap
92
92
  # postgresql package install starts postgresql, so stop it
93
93
  rsudo "#{rubber_env.postgresql_ctl} stop" rescue nil
94
-
94
+
95
95
  # After everything installed on machines, we need the source tree
96
96
  # on hosts in order to run rubber:config for bootstrapping the db
97
97
  rubber.update_code_for_bootstrap
@@ -114,15 +114,15 @@ namespace :rubber do
114
114
  task :promote_slave do
115
115
  master_alias = get_env('MASTER', "Master alias (e.g. db01)", true)
116
116
  slave_alias = get_env('SLAVE', "Slave alias (e.g. db02)", true)
117
-
117
+
118
118
  # remove the master instance so rubber doesn't try to deploy to it
119
119
  # Stays running so needs to be manually deleted
120
120
  master_instance = rubber_instances.remove(master_alias)
121
121
  fatal "Master Instance does not exist: #{master_alias}" unless master_instance
122
-
122
+
123
123
  slave_instance = rubber_instances[slave_alias]
124
124
  fatal "Slave Instance does not exist: #{slave_alias}" unless slave_instance
125
-
125
+
126
126
  # remove all db roles from slave
127
127
  slave_instance.roles.delete_if {|ir| ir.name =~ /db|postgresql/ }
128
128
 
@@ -130,9 +130,9 @@ namespace :rubber do
130
130
  new_roles = [Rubber::Configuration::RoleItem.parse("postgresql_master")]
131
131
  new_roles = Rubber::Configuration::RoleItem.expand_role_dependencies(new_roles, get_role_dependencies)
132
132
  slave_instance.roles = (slave_instance.roles + new_roles).uniq
133
-
133
+
134
134
  rubber_instances.save()
135
-
135
+
136
136
  begin
137
137
  Timeout::timeout(10) do
138
138
  logger.info "Stopping server on original master #{master_alias}"
@@ -142,10 +142,10 @@ namespace :rubber do
142
142
  rescue StandardError
143
143
  logger.info "Failed to connect to original master, promoting slave anyway"
144
144
  end
145
-
145
+
146
146
  logger.info "Triggering slave promotion on new master #{slave_alias}"
147
147
  rsudo "touch #{rubber_env.postgresql_data_dir}/trigger_file", :hosts => slave_instance.full_name
148
-
148
+
149
149
  logger.info "The master instance has been removed from instances, but remains running:"
150
150
  logger.info "#{master_alias}, #{master_instance.instance_id}, #{master_instance.external_ip}"
151
151
  logger.info ''
@@ -161,14 +161,14 @@ namespace :rubber do
161
161
  task :start, :roles => [:postgresql_master, :postgresql_slave] do
162
162
  rsudo "#{rubber_env.postgresql_ctl} start"
163
163
  end
164
-
164
+
165
165
  desc <<-DESC
166
166
  Stops the postgresql daemons
167
167
  DESC
168
168
  task :stop, :roles => [:postgresql_master, :postgresql_slave] do
169
169
  rsudo "#{rubber_env.postgresql_ctl} stop || true"
170
170
  end
171
-
171
+
172
172
  desc <<-DESC
173
173
  Restarts the postgresql daemons
174
174
  DESC
@@ -179,4 +179,4 @@ namespace :rubber do
179
179
 
180
180
  end
181
181
 
182
- end
182
+ end
@@ -28,10 +28,14 @@ class AwsTest < Test::Unit::TestCase
28
28
  should "create instance" do
29
29
  assert @cloud.create_instance('', '', '', '', '', '')
30
30
  end
31
+
32
+ should "create instance with opts" do
33
+ assert @cloud.create_instance('', '', '', '', '', '', :ebs_optimized => true)
34
+ end
31
35
  end
32
36
 
33
37
  context "aws with alternative region" do
34
-
38
+
35
39
  setup do
36
40
  @region = "ap-southeast-2"
37
41
  env = {'access_key' => "XXX", 'secret_access_key' => "YYY", 'region' => @region}
@@ -32,5 +32,8 @@ class FogTest < Test::Unit::TestCase
32
32
  assert @cloud.create_instance('', '', '', '', '', '')
33
33
  end
34
34
 
35
+ should "create instance with options" do
36
+ assert @cloud.create_instance('', '', '', '', '', '', :foo => :bar)
37
+ end
35
38
  end
36
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-14 00:00:00.000000000 Z
12
+ date: 2014-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement