cloud-maker 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -407,6 +407,10 @@ module CloudMaker
407
407
  # precedence to all values set in this one. Arrays will be merged as
408
408
  # imported_array.concat(current_array).uniq.
409
409
  #
410
+ # "--" can be used as a knockout prefix, ie. "--foo" will delete the key "foo"
411
+ # when an array is merged, or "--" will delete the entire existing contents of
412
+ # the array.
413
+ #
410
414
  # It should be noted that this is not reference safe, ie. objects within
411
415
  # cloud_maker_config will end up referenced from this config object as well.
412
416
  #
@@ -414,11 +418,18 @@ module CloudMaker
414
418
  #
415
419
  # Returns nothing.
416
420
  def import(cloud_maker_config)
417
- self.options = cloud_maker_config.options.deep_merge!(self.options)
418
- self.includes = cloud_maker_config.includes.concat(self.includes).uniq
419
- self.imports = cloud_maker_config.imports.concat(self.imports).uniq
420
- self.cloud_config = cloud_maker_config.cloud_config.deep_merge!(self.cloud_config)
421
- self.extra_options = cloud_maker_config.extra_options.deep_merge!(self.extra_options)
421
+ [:options, :includes, :imports, :cloud_config, :extra_options].each do |key|
422
+ key = key.to_sym
423
+ #toss both of these into a hash because deep_merge only works on hashes
424
+ cloud_maker_config_hash = {:value => cloud_maker_config.send(key)}
425
+ self_hash = {:value => self.send(key)}
426
+ self.send(
427
+ :"#{key}=",
428
+ cloud_maker_config_hash.deep_merge!(
429
+ self_hash, :preserve_unmergeables => false, :knockout_prefix => '--'
430
+ )[:value]
431
+ )
432
+ end
422
433
  end
423
434
  end
424
435
  end
@@ -42,6 +42,9 @@ module CloudMaker
42
42
  'cname' => {
43
43
  'default' => '',
44
44
  'description' => "A dns entry you would like to CNAME to this instance."
45
+ },
46
+ 'block_device_mappings' => {
47
+ 'description' => "A hash of block devices mappings. ie. { /dev/sda1 => { volume_size => <value_in_GB>, snapshot_id => <id>, delete_on_termination => <boolean> } }"
45
48
  }
46
49
  }
47
50
  }
@@ -107,7 +110,8 @@ module CloudMaker
107
110
  else
108
111
  region = ec2 # .instances.create will just put things in the default region
109
112
  end
110
- instance = region.instances.create(
113
+
114
+ config = {
111
115
  :image_id => cloud_maker_config['ami'],
112
116
  :iam_instance_profile => cloud_maker_config['iam_role'],
113
117
  :security_groups => cloud_maker_config['security_group'],
@@ -115,10 +119,21 @@ module CloudMaker
115
119
  :key_name => cloud_maker_config['key_pair'],
116
120
  :availability_zone => cloud_maker_config['availability_zone'],
117
121
  :user_data => user_data
118
- )
122
+ }
123
+ config[:block_device_mappings] = cloud_maker_config['block_device_mappings'] if cloud_maker_config['block_device_mappings']
124
+
125
+ instance = region.instances.create(config)
119
126
 
120
127
  begin
121
- instance.tags.set(cloud_maker_config['tags']) if cloud_maker_config['tags']
128
+ if cloud_maker_config['tags']
129
+ # we can only set tags to be strings so make sure we convert all of our tags
130
+ # to strings
131
+ string_tags = cloud_maker_config['tags'].inject({}) do |hash, pair|
132
+ hash[pair[0]] = pair[1].to_s
133
+ hash
134
+ end
135
+ instance.tags.set(string_tags)
136
+ end
122
137
  rescue AWS::EC2::Errors::InvalidInstanceID::NotFound => e
123
138
  retries ||= 0
124
139
  if retries < 5
@@ -21,7 +21,7 @@ module CloudMaker
21
21
  end
22
22
 
23
23
  def execute
24
- @result ||= `#{self.script}`.chomp
24
+ @result ||= `#{self.script}`.strip
25
25
  end
26
26
 
27
27
  def to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-03 00:00:00.000000000 Z
13
+ date: 2012-10-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: colorize
@@ -124,7 +124,12 @@ dependencies:
124
124
  - - ! '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
- description:
127
+ description: CloudMaker is a tool for launching and configuring EC2 instances. It
128
+ works as an extension to the Ubuntu CloudInit system. It extends the configuration
129
+ format with a composition system and options to describe how you want an instance
130
+ to be launched. The goal of the project is to make building and launching instances
131
+ simple and repeatable. It accomplishes this by leveraging existing toolchains rather
132
+ than forcing people to learn a new and complicated system.
128
133
  email: nathan.baxter@airbnb.com
129
134
  executables:
130
135
  - cloud-maker