conan 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/conan CHANGED
@@ -16,7 +16,7 @@ Commands:
16
16
  Options:
17
17
  END
18
18
 
19
- settings = Conan::Settings.new
19
+ settings = {}
20
20
 
21
21
  opts = ARGV.options{ |o|
22
22
  o.banner << " command"
@@ -48,41 +48,43 @@ module AWS
48
48
  region = new_conf[:region] || "us-east-1"
49
49
 
50
50
  compute = Fog::Compute.new(:provider => :aws, :region => region)
51
- default_key_name = compute.key_pairs.all.first.name
52
51
 
53
- default_params = { :instance_monitoring => true,
54
- :instance_type => "m1.small",
55
- :key_name => default_key_name
56
- }
57
-
58
- params = default_params.merge(new_conf)
52
+ params = {}
53
+ params['KeyName'] = new_conf[:key_name] || compute.key_pairs.all.first.name
59
54
 
60
55
  if new_conf[:security_groups] and new_conf[:security_groups].size > 0
61
- params[:security_groups] = new_conf[:security_groups].collect { |g| "#{stage}-#{g}" }
56
+ params['SecurityGroups'] = new_conf[:security_groups].collect { |g| "#{stage}-#{g}" }
62
57
  else
63
- params[:security_groups] = ["#{stage}-default"]
58
+ params['SecurityGroups'] = ["#{stage}-default"]
64
59
  end
65
60
 
66
- if params[:server_to_image].nil?
67
- params[:image_id] = default_image_id(region, params[:flavor_id], params[:root_device_type]) if params[:image_id].nil?
61
+ instance_type = new_conf.delete(:instance_type) || "m1.small"
62
+
63
+ if new_conf[:server_to_image].nil?
64
+ if new_conf[:image_id].nil?
65
+ image_id = default_image_id(region, instance_type, new_conf[:root_device_type])
66
+ else
67
+ image_id = new_conf[:image_id]
68
+ end
68
69
  else
69
- params[:image_id] = create_ami_from_server(params[:server_to_image], region) end
70
+ image_id = create_ami_from_server(new_conf[:server_to_image], region)
71
+ end
70
72
 
71
73
  autoscale = Fog::AWS::AutoScaling.new(:region => region)
72
74
 
73
75
  #need to create new launchconfiugrations with unique names
74
76
  #because you can't modify them and you can't delete them if they are attached
75
77
  #to an autoscale group
76
- params[:id] = "#{ec2_name_tag(name)}-#{Time.now.strftime('%Y%m%d%H%M')}"
78
+ id = "#{ec2_name_tag(name)}-#{Time.now.strftime('%Y%m%d%H%M')}"
77
79
 
78
- puts "Creating Autoscale Launch Configuration #{params[:id]}"
79
- lc = autoscale.configurations.create(params)
80
+ puts "Creating Autoscale Launch Configuration #{id}"
81
+ lc = autoscale.configurations.connection.create_launch_configuration(image_id, instance_type, id, params)
80
82
 
81
- params[:autoscale_groups].each do |group_name|
83
+ new_conf[:autoscale_groups].each do |group_name|
82
84
  asg = autoscale.groups.get(group_name)
83
- "Setting Autoscale Group #{group_name} to use Launch Configration #{params[:id]}"
84
- asg.connection.update_auto_scaling_group(asg.id, {"LaunchConfigurationName" => params[:id]})
85
- end unless params[:autoscale_groups].nil?
85
+ "Setting Autoscale Group #{group_name} to use Launch Configration #{id}"
86
+ asg.connection.update_auto_scaling_group(asg.id, {"LaunchConfigurationName" => id})
87
+ end unless new_conf[:autoscale_groups].nil?
86
88
 
87
89
  end
88
90
 
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'fog/aws/requests/auto_scaling/create_launch_configuration'
3
+
4
+ module Fog
5
+ module AWS
6
+ class AutoScaling
7
+
8
+ class Real
9
+
10
+ def create_launch_configuration(image_id, instance_type, launch_configuration_name, options = {})
11
+ if block_device_mappings = options.delete('BlockDeviceMappings')
12
+ block_device_mappings.each_with_index do |mapping, i|
13
+ for key, value in mapping
14
+ options.merge!({ format("BlockDeviceMappings.member.%d.#{key}", i+1) => value })
15
+ end
16
+ end
17
+ end
18
+ if security_groups = options.delete('SecurityGroups')
19
+ options.merge!(Fog::AWS.indexed_param('SecurityGroup.member', [*security_groups]))
20
+ end
21
+ if options['UserData']
22
+ options['UserData'] = Base64.encode64(options['UserData'])
23
+ end
24
+
25
+ request({
26
+ 'Action' => 'CreateLaunchConfiguration',
27
+ 'ImageId' => image_id,
28
+ 'InstanceType' => instance_type,
29
+ 'LaunchConfigurationName' => launch_configuration_name,
30
+ :parser => Fog::Parsers::AWS::AutoScaling::Basic.new
31
+ }.merge!(options))
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -32,7 +32,10 @@ module AWS
32
32
  servers.each do |server|
33
33
  if server.tags["stage"] == st
34
34
  config = {}
35
- config["roles"] = server.tags["roles"].split(", ") unless server.tags["roles"].nil?
35
+ unless server.tags["roles"].nil?
36
+ config["roles"] = server.tags["roles"].split(", ")
37
+ config["roles"] = server.tags["roles"].split(":") unless config["roles"].length > 1
38
+ end
36
39
  config["alias"] = server.tags["name"]
37
40
  if filter_role.nil? || config["roles"].include?(filter_role)
38
41
  server_config[st][server.dns_name] = config
@@ -56,7 +56,7 @@ module AWS
56
56
  when "us-west-1"
57
57
  ["us-west-1a", "us-west-1b", "us-west-1c"]
58
58
  when "eu-west-1"
59
- ["eu-west-1a", "eu-west-1b"]
59
+ ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
60
60
  when "ap-northeast-1"
61
61
  ["ap-northeast-1a", "ap-northeast-1a"]
62
62
  when "ap-southeast-1"
@@ -40,7 +40,7 @@ module Conan
40
40
  roles.each do |r, ss|
41
41
  next unless roles.include?(r)
42
42
  ss.each_with_index do |s, i|
43
- role r, s, :primary => (i == 0)
43
+ role r, s, :primary => (i == 0), :no_release => !roles[:app].include?(s)
44
44
  end
45
45
  end
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module Conan
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-27 00:00:00.000000000Z
13
+ date: 2012-02-28 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
17
- requirement: &70281889180960 !ruby/object:Gem::Requirement
17
+ requirement: &70360746833680 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.6.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70281889180960
25
+ version_requirements: *70360746833680
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: capistrano
28
- requirement: &70281889178900 !ruby/object:Gem::Requirement
28
+ requirement: &70360746833020 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70281889178900
36
+ version_requirements: *70360746833020
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: fog
39
- requirement: &70281889177220 !ruby/object:Gem::Requirement
39
+ requirement: &70360746832000 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70281889177220
47
+ version_requirements: *70360746832000
48
48
  description: Set up a project to enable the provision of infrastructure through AWS
49
49
  and the configuration of servers using Chef via Capistrano.
50
50
  email:
@@ -57,6 +57,7 @@ files:
57
57
  - bin/conan
58
58
  - lib/conan/capistrano.rb
59
59
  - lib/conan/cloud/aws/autoscale.rb
60
+ - lib/conan/cloud/aws/create_launch_configuration.rb
60
61
  - lib/conan/cloud/aws/default_amis.json
61
62
  - lib/conan/cloud/aws/provision.rb
62
63
  - lib/conan/cloud/aws/security_group.rb