provisionator 0.0.18 → 0.0.19
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.
- checksums.yaml +4 -4
- data/lib/provisionator/ec2_launcher.rb +20 -12
- data/lib/provisionator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82963adf7311538addb67d420d72022bf7167892
|
4
|
+
data.tar.gz: d12766be8959ff559f47e09a72dfa2d22531a560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a4bb193ebc56d38ae0e858e747077c38173c295b12c68aec90d6e041c9d3b236f128237c4073567c959b8278173aff5639e2a0415bcfd8152aa2e7d6b9e7205
|
7
|
+
data.tar.gz: 56b7312f688f3e74e4a1498d973dcbce2927be42dec329230d9f53a1a1f431bc4c3488ca712b42c83751e947523f9b86ee4740a687f00fd650d53b12749b834e
|
@@ -10,17 +10,18 @@ module Provisionator
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize options={}
|
13
|
-
|
13
|
+
%w{ AWS_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY}.each do |env_var|
|
14
|
+
raise "ENV['#{env_var}'] is required to be set" unless ENV[env_var]
|
15
|
+
end
|
14
16
|
|
17
|
+
@options = options
|
15
18
|
@options[:instance_type] ||= ENV['P_INSTANCE_TYPE'] || 'm1.small'
|
16
19
|
@options[:no_release] ||= ENV['P_NO_RELEASE']
|
17
|
-
@options[:
|
18
|
-
@options[:ec2_endpoint] ||= ENV['P_EC2_ENDPOINT'] || "ec2.#{@options[:ec2_region]}.amazonaws.com"
|
19
|
-
@options[:ami_id] ||= ENV['P_AMI_ID']
|
20
|
+
@options[:ami_id] ||= ENV['P_AMI_ID'] || ami_id
|
20
21
|
@options[:ebs_volumes] ||= []
|
21
22
|
@options[:key_name] ||= ENV['P_KEY_NAME']
|
22
23
|
@options[:security_groups] ||= ENV['P_SECURITY_GROUPS'].try(:split, ',')
|
23
|
-
@options[:availability_zones] ||= ENV['P_AVAILABILITY_ZONES'].try(:split, ',') || ec2.
|
24
|
+
@options[:availability_zones] ||= ENV['P_AVAILABILITY_ZONES'].try(:split, ',') || ec2.availability_zones.map(&:name)
|
24
25
|
@options[:instance_count] ||= ENV['P_INSTANCE_COUNT'].try(:to_i) || 1
|
25
26
|
@options[:load_balancer_name] ||= ENV['P_LOAD_BALANCER_NAME']
|
26
27
|
|
@@ -44,10 +45,21 @@ module Provisionator
|
|
44
45
|
|
45
46
|
private
|
46
47
|
|
48
|
+
def ami_id
|
49
|
+
case ENV['AWS_REGION']
|
50
|
+
when 'us-east-1'
|
51
|
+
'ami-bbf799d2'
|
52
|
+
when 'ap-southeast-2'
|
53
|
+
'ami-6bcf5c51'
|
54
|
+
else
|
55
|
+
raise "no ami-id defined for region '#{ENV['AWS_REGION']}'"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
def assign_elastic_ip instance
|
48
60
|
return unless @options[:elastic_ip]
|
49
61
|
puts "Assigning #{@options[:elastic_ip]} to #{instance.id}"
|
50
|
-
|
62
|
+
ec2.client.associate_address instance_id: instance.id, public_ip: @options[:elastic_ip]
|
51
63
|
end
|
52
64
|
|
53
65
|
def register_with_load_balancer instances
|
@@ -86,16 +98,12 @@ module Provisionator
|
|
86
98
|
end
|
87
99
|
end
|
88
100
|
|
89
|
-
def ec2_client
|
90
|
-
@ec2_client ||= AWS::EC2::Client.new(ec2_endpoint: "ec2.#{@options[:ec2_region]}.amazonaws.com")
|
91
|
-
end
|
92
|
-
|
93
101
|
def ec2
|
94
|
-
@ec2 ||= AWS::EC2.new
|
102
|
+
@ec2 ||= AWS::EC2.new
|
95
103
|
end
|
96
104
|
|
97
105
|
def elb
|
98
|
-
@elb ||= AWS::ELB::Client.new
|
106
|
+
@elb ||= AWS::ELB::Client.new
|
99
107
|
end
|
100
108
|
|
101
109
|
def user_data attributes={}
|