rivet 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -4
- data/.travis.yml +5 -5
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +42 -26
- data/README.md +61 -10
- data/bin/rivet +14 -9
- data/example/ec2/defaults.rb +6 -0
- data/example/ec2/example.rb +8 -0
- data/example/ec2/user_data.erb +2 -0
- data/lib/rivet/{autoscale.rb → as/autoscale.rb} +33 -4
- data/lib/rivet/{config.rb → as/autoscale_config.rb} +3 -33
- data/lib/rivet/{launch_config.rb → as/launch_config.rb} +8 -11
- data/lib/rivet/{aws_utils.rb → common/aws_utils.rb} +27 -29
- data/lib/rivet/common/base_aws_attributes.rb +15 -0
- data/lib/rivet/common/base_config.rb +40 -0
- data/lib/rivet/{client.rb → common/client.rb} +11 -10
- data/lib/rivet/ec2/ec2.rb +163 -0
- data/lib/rivet/ec2/ec2_config.rb +19 -0
- data/lib/rivet/utils.rb +4 -3
- data/lib/rivet/version.rb +1 -1
- data/lib/rivet.rb +16 -11
- data/rivet.gemspec +6 -5
- data/spec/as/autoscale_config_spec.rb +65 -0
- data/spec/{aws_autoscale_wrapper_spec.rb → as/aws_autoscale_wrapper_spec.rb} +1 -1
- data/spec/aws_utils_spec.rb +44 -0
- data/spec/base_config_spec.rb +31 -0
- data/spec/bootstrap_spec.rb +1 -1
- data/spec/ec2/ec2_config_spec.rb +29 -0
- data/spec/launch_config_spec.rb +1 -1
- data/spec/shared_examples/a_config.rb +98 -0
- data/spec/shared_examples/a_config_util.rb +33 -0
- data/spec/spec_setup.rb +63 -39
- data/spec/util_spec.rb +16 -23
- metadata +63 -43
- data/lib/rivet/deep_merge.rb +0 -29
- data/spec/config_spec.rb +0 -168
- /data/lib/rivet/{aws_autoscale_wrapper.rb → as/aws_autoscale_wrapper.rb} +0 -0
- /data/lib/rivet/{bootstrap.rb → common/bootstrap.rb} +0 -0
- /data/lib/rivet/{config_proxy.rb → common/config_proxy.rb} +0 -0
- /data/lib/rivet/{logger.rb → common/logger.rb} +0 -0
- /data/lib/rivet/{open_state.rb → common/open_state.rb} +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29038451ff7a607f2b7a987620d1b269b5ffad06
|
4
|
+
data.tar.gz: 4fc0b891b7440d8f5dac41bf62100b33f5549c3b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c91c7c5e65035d72314c673626f6402b4995bc7809ca50bf58fc6ed4c2367be11e8a1b69052bcb3f833ada13f7f2486f4a2b95a44fc455fee47029fb7430d4b
|
7
|
+
data.tar.gz: c763546bf997532698826304473fa755d108b8f54d0f991238aa9e4bf4341692ec790812db28715362e7ac9d7ce0f918ae6969bff9608e93ede9b5ae47ee4534
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Rivet CHANGELOG
|
2
2
|
===
|
3
3
|
|
4
|
+
3.0.0 -
|
5
|
+
---
|
6
|
+
* Adds functionality to launch regular EC2 instances
|
7
|
+
* A diff is now displayed for launch configurations
|
8
|
+
* Bug Fix: The tags array is now sorted alphabetically by key (as this is how the SDK
|
9
|
+
seems to return it now)
|
10
|
+
|
4
11
|
2.0.0 -
|
5
12
|
---
|
6
13
|
* Completely rewrite of the configuration system to use a DSL instead of YAML
|
data/Gemfile
CHANGED
@@ -3,8 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'rubysl', platform: :rbx
|
4
4
|
|
5
5
|
group(:development, :test) do
|
6
|
-
gem '
|
7
|
-
gem '
|
6
|
+
gem 'rubocop'
|
7
|
+
gem 'rake', '>= 10.1.0'
|
8
|
+
gem 'rspec', '~> 2.14.1'
|
8
9
|
end
|
9
10
|
|
10
11
|
gem 'aws-sdk', '>= 1.11.1'
|
12
|
+
gem 'diff-lcs', '>= 1.2.5'
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,45 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
4
|
+
ast (2.0.0)
|
5
|
+
astrolabe (1.3.0)
|
6
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
7
|
+
aws-sdk (1.59.0)
|
8
|
+
aws-sdk-v1 (= 1.59.0)
|
9
|
+
aws-sdk-v1 (1.59.0)
|
5
10
|
json (~> 1.4)
|
6
11
|
nokogiri (>= 1.4.4)
|
7
|
-
uuidtools (~> 2.1)
|
8
12
|
diff-lcs (1.2.5)
|
9
13
|
ffi2-generators (0.1.1)
|
10
14
|
json (1.8.1)
|
11
15
|
json (1.8.1-java)
|
12
|
-
mini_portile (0.
|
13
|
-
nokogiri (1.6.1)
|
14
|
-
mini_portile (~> 0.
|
15
|
-
nokogiri (1.6.1-java)
|
16
|
-
|
17
|
-
|
16
|
+
mini_portile (0.6.1)
|
17
|
+
nokogiri (1.6.4.1)
|
18
|
+
mini_portile (~> 0.6.0)
|
19
|
+
nokogiri (1.6.4.1-java)
|
20
|
+
parser (2.2.0.pre.8)
|
21
|
+
ast (>= 1.1, < 3.0)
|
22
|
+
slop (~> 3.4, >= 3.4.5)
|
23
|
+
powerpack (0.0.9)
|
24
|
+
rainbow (2.0.0)
|
25
|
+
rake (10.4.0)
|
26
|
+
rb-readline (0.5.1)
|
18
27
|
rspec (2.14.1)
|
19
28
|
rspec-core (~> 2.14.0)
|
20
29
|
rspec-expectations (~> 2.14.0)
|
21
30
|
rspec-mocks (~> 2.14.0)
|
22
|
-
rspec-core (2.14.
|
31
|
+
rspec-core (2.14.8)
|
23
32
|
rspec-expectations (2.14.5)
|
24
33
|
diff-lcs (>= 1.1.3, < 2.0)
|
25
|
-
rspec-mocks (2.14.
|
26
|
-
|
34
|
+
rspec-mocks (2.14.6)
|
35
|
+
rubocop (0.27.1)
|
36
|
+
astrolabe (~> 1.3)
|
37
|
+
parser (>= 2.2.0.pre.7, < 3.0)
|
38
|
+
powerpack (~> 0.0.6)
|
39
|
+
rainbow (>= 1.99.1, < 3.0)
|
40
|
+
ruby-progressbar (~> 1.4)
|
41
|
+
ruby-progressbar (1.7.0)
|
42
|
+
rubysl (2.1.0)
|
27
43
|
rubysl-abbrev (~> 2.0)
|
28
44
|
rubysl-base64 (~> 2.0)
|
29
45
|
rubysl-benchmark (~> 2.0)
|
@@ -57,7 +73,7 @@ GEM
|
|
57
73
|
rubysl-io-nonblock (~> 2.0)
|
58
74
|
rubysl-io-wait (~> 2.0)
|
59
75
|
rubysl-ipaddr (~> 2.0)
|
60
|
-
rubysl-irb (~> 2.
|
76
|
+
rubysl-irb (~> 2.1)
|
61
77
|
rubysl-logger (~> 2.0)
|
62
78
|
rubysl-mathn (~> 2.0)
|
63
79
|
rubysl-matrix (~> 2.0)
|
@@ -86,7 +102,6 @@ GEM
|
|
86
102
|
rubysl-pstore (~> 2.0)
|
87
103
|
rubysl-pty (~> 2.0)
|
88
104
|
rubysl-rational (~> 2.0)
|
89
|
-
rubysl-readline (~> 2.0)
|
90
105
|
rubysl-resolv (~> 2.0)
|
91
106
|
rubysl-rexml (~> 2.0)
|
92
107
|
rubysl-rinda (~> 2.0)
|
@@ -128,7 +143,7 @@ GEM
|
|
128
143
|
rubysl-csv (2.0.2)
|
129
144
|
rubysl-english (~> 2.0)
|
130
145
|
rubysl-curses (2.0.1)
|
131
|
-
rubysl-date (2.0.
|
146
|
+
rubysl-date (2.0.8)
|
132
147
|
rubysl-delegate (2.0.1)
|
133
148
|
rubysl-digest (2.0.3)
|
134
149
|
rubysl-drb (2.0.1)
|
@@ -153,12 +168,12 @@ GEM
|
|
153
168
|
rubysl-io-nonblock (2.0.0)
|
154
169
|
rubysl-io-wait (2.0.0)
|
155
170
|
rubysl-ipaddr (2.0.0)
|
156
|
-
rubysl-irb (2.0
|
171
|
+
rubysl-irb (2.1.0)
|
172
|
+
rb-readline (~> 0.5)
|
157
173
|
rubysl-e2mmap (~> 2.0)
|
158
174
|
rubysl-mathn (~> 2.0)
|
159
|
-
rubysl-readline (~> 2.0)
|
160
175
|
rubysl-thread (~> 2.0)
|
161
|
-
rubysl-logger (2.
|
176
|
+
rubysl-logger (2.1.0)
|
162
177
|
rubysl-mathn (2.0.0)
|
163
178
|
rubysl-matrix (2.1.0)
|
164
179
|
rubysl-e2mmap (~> 2.0)
|
@@ -181,21 +196,20 @@ GEM
|
|
181
196
|
rubysl-observer (2.0.0)
|
182
197
|
rubysl-open-uri (2.0.0)
|
183
198
|
rubysl-open3 (2.0.0)
|
184
|
-
rubysl-openssl (2.1
|
199
|
+
rubysl-openssl (2.2.1)
|
185
200
|
rubysl-optparse (2.0.1)
|
186
201
|
rubysl-shellwords (~> 2.0)
|
187
202
|
rubysl-ostruct (2.0.4)
|
188
|
-
rubysl-pathname (2.
|
189
|
-
rubysl-prettyprint (2.0.
|
203
|
+
rubysl-pathname (2.1.0)
|
204
|
+
rubysl-prettyprint (2.0.3)
|
190
205
|
rubysl-prime (2.0.1)
|
191
206
|
rubysl-profile (2.0.0)
|
192
207
|
rubysl-profiler (2.0.1)
|
193
208
|
rubysl-pstore (2.0.0)
|
194
209
|
rubysl-pty (2.0.2)
|
195
210
|
rubysl-rational (2.0.1)
|
196
|
-
rubysl-
|
197
|
-
rubysl-
|
198
|
-
rubysl-rexml (2.0.2)
|
211
|
+
rubysl-resolv (2.1.0)
|
212
|
+
rubysl-rexml (2.0.4)
|
199
213
|
rubysl-rinda (2.0.1)
|
200
214
|
rubysl-rss (2.0.0)
|
201
215
|
rubysl-scanf (2.0.0)
|
@@ -207,14 +221,14 @@ GEM
|
|
207
221
|
rubysl-stringio (2.0.0)
|
208
222
|
rubysl-strscan (2.0.0)
|
209
223
|
rubysl-sync (2.0.0)
|
210
|
-
rubysl-syslog (2.0
|
224
|
+
rubysl-syslog (2.1.0)
|
211
225
|
ffi2-generators (~> 0.1)
|
212
226
|
rubysl-tempfile (2.0.1)
|
213
227
|
rubysl-thread (2.0.2)
|
214
228
|
rubysl-thwait (2.0.0)
|
215
229
|
rubysl-time (2.0.3)
|
216
230
|
rubysl-timeout (2.0.0)
|
217
|
-
rubysl-tmpdir (2.0.
|
231
|
+
rubysl-tmpdir (2.0.1)
|
218
232
|
rubysl-tsort (2.0.1)
|
219
233
|
rubysl-un (2.0.0)
|
220
234
|
rubysl-fileutils (~> 2.0)
|
@@ -225,7 +239,7 @@ GEM
|
|
225
239
|
rubysl-xmlrpc (2.0.0)
|
226
240
|
rubysl-yaml (2.0.4)
|
227
241
|
rubysl-zlib (2.0.1)
|
228
|
-
|
242
|
+
slop (3.6.0)
|
229
243
|
|
230
244
|
PLATFORMS
|
231
245
|
java
|
@@ -233,6 +247,8 @@ PLATFORMS
|
|
233
247
|
|
234
248
|
DEPENDENCIES
|
235
249
|
aws-sdk (>= 1.11.1)
|
250
|
+
diff-lcs (>= 1.2.5)
|
236
251
|
rake (>= 10.1.0)
|
237
252
|
rspec (~> 2.14.1)
|
253
|
+
rubocop
|
238
254
|
rubysl
|
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Rivet
|
4
4
|
=======
|
5
|
-
Rivet enables you to describe autoscaling groups
|
5
|
+
Rivet enables you to describe autoscaling groups, their launch configurations, and regular EC2 instances as configuration. You can then sync those changes to Amazon Web Services (AWS.)
|
6
6
|
|
7
|
-
You optionally provide a template and it's options to render as user-data for your launch configurations.
|
7
|
+
You optionally provide a template and it's options to render as user-data for your launch configurations or EC2 instances.
|
8
8
|
|
9
9
|
Rivet generates unique deterministic names for launch configurations and automatically assigns the proper launch configuration to your
|
10
10
|
autoscaling group based upon it's generated identity.
|
@@ -51,16 +51,18 @@ You will still need to specify the region to use in your `AWS_CONFIG_FILE`.
|
|
51
51
|
Rivet will use the [default] profile if you do not specify a profile to use with the -p [--profile] option.
|
52
52
|
|
53
53
|
|
54
|
-
|
54
|
+
Definition directories and files
|
55
55
|
--------------------------------------------------
|
56
56
|
|
57
57
|
Example files can be found in the example/ directory in the rivet git repository
|
58
58
|
|
59
|
-
Rivet will look in the directory specified on the command line (or ./
|
59
|
+
Rivet will look in the directory specified on the command line (./autoscale or ./ec2 by default) for configuration files. It expects the configuration file name to match the name of the autoscaling group or EC2 instance.
|
60
60
|
|
61
61
|
```
|
62
62
|
./autoscale
|
63
|
-
`-
|
63
|
+
`- name.rb
|
64
|
+
./ec2
|
65
|
+
`- name.rb
|
64
66
|
```
|
65
67
|
|
66
68
|
Configuration DSL
|
@@ -88,6 +90,8 @@ user-data.
|
|
88
90
|
|
89
91
|
Rivet will only use the following attributes.
|
90
92
|
|
93
|
+
|
94
|
+
Autoscale Options
|
91
95
|
```
|
92
96
|
min_size INTEGER <required>
|
93
97
|
max_size INTEGER <required>
|
@@ -101,7 +105,33 @@ load_balancers ARRAY <optional, default nil)
|
|
101
105
|
subnet ARRAY <optional, default nil)
|
102
106
|
iam_instance_profile STRING <optional, default nil)
|
103
107
|
tags ARRAY <optional, default nil)
|
108
|
+
block_device_mapping ARRAY <optional, default nil>
|
109
|
+
```
|
104
110
|
|
111
|
+
EC2 Options
|
112
|
+
```
|
113
|
+
count INTEGER <required>
|
114
|
+
image_id STRING <required>
|
115
|
+
iam_instance_profile STRING <optional>
|
116
|
+
block_device_mapping ARRAY <optional>
|
117
|
+
monitoring_enabled BOOLEAN <optional>
|
118
|
+
availability_zone STRING <optional>
|
119
|
+
placement_group STRING <optional>
|
120
|
+
key_name STRING <optional>
|
121
|
+
security_groups ARRAY <optional>
|
122
|
+
security_group_ids ARRAY <optional>
|
123
|
+
instance_type STRING <optional>
|
124
|
+
kernel_id STRING <optional>
|
125
|
+
ramdisk_id STRING <optional>
|
126
|
+
disable_api_termination BOOLEAN <optional>
|
127
|
+
instance_initiated_shutdown_behavior STRING <optional>
|
128
|
+
subnet STRING <optional>
|
129
|
+
private_ip_address STRING <optional>
|
130
|
+
dedicated_tenancy BOOLEAN <optional>
|
131
|
+
ebs_optimized BOOLEAN <optional>
|
132
|
+
associate_public_ip_address BOOLEAN <optional>
|
133
|
+
elastic_ips ARRAY <optional>
|
134
|
+
network_interfaces ARRAY <optional>
|
105
135
|
```
|
106
136
|
|
107
137
|
Availability zones should use the single character of the zone ('a', 'b','c'). The region will be appended by rivet.
|
@@ -111,6 +141,19 @@ Tags should be an Array of Hashes with the format:
|
|
111
141
|
value: String,
|
112
142
|
propogate_at_launch: True/False <optional, default True>'}
|
113
143
|
|
144
|
+
Block device mappings should be an array of Hashes with the format:
|
145
|
+
{
|
146
|
+
virtual_name: String,
|
147
|
+
device_name: String,
|
148
|
+
ebs: {
|
149
|
+
snapshot_id: String
|
150
|
+
volume_size: Integer
|
151
|
+
delete_on_termination: Boolean
|
152
|
+
volume_type: String
|
153
|
+
iops: Integer
|
154
|
+
}
|
155
|
+
no_device: String
|
156
|
+
}
|
114
157
|
|
115
158
|
Using the bootstrap functionality
|
116
159
|
---------------------------------
|
@@ -140,8 +183,10 @@ Usage
|
|
140
183
|
=====
|
141
184
|
|
142
185
|
```
|
143
|
-
Usage: rivet [options]
|
144
|
-
-
|
186
|
+
Usage: rivet sub-command [options]
|
187
|
+
sub-commands: ec2, autoscale
|
188
|
+
|
189
|
+
-n, --name [NAME] Server or Autoscaling group name
|
145
190
|
-l, --log-level [LEVEL] specify the log level (default is INFO)
|
146
191
|
-p, --profile [PROFILE_NAME] Selects the AWS profile to use (default is 'default')
|
147
192
|
-s, --sync Sync the changes remotely to AWS
|
@@ -149,21 +194,27 @@ Usage: rivet [options]
|
|
149
194
|
-h
|
150
195
|
```
|
151
196
|
|
197
|
+
launch an ec2 instance
|
198
|
+
|
199
|
+
```bash
|
200
|
+
rivet ec2 -n example_instance
|
201
|
+
```
|
202
|
+
|
152
203
|
check the differences for the example_group autoscaling group
|
153
204
|
|
154
205
|
```bash
|
155
|
-
rivet -
|
206
|
+
rivet autoscale -n example_group
|
156
207
|
```
|
157
208
|
|
158
209
|
check the differences for the example_group using the foobar profile
|
159
210
|
|
160
211
|
```bash
|
161
|
-
rivet -
|
212
|
+
rivet autoscale -n example_group -p foobar
|
162
213
|
```
|
163
214
|
|
164
215
|
sync the differences for the example_group using the foobar profile
|
165
216
|
|
166
217
|
```bash
|
167
|
-
rivet -
|
218
|
+
rivet autoscale -n example_group -p foobar -s
|
168
219
|
```
|
169
220
|
|
data/bin/rivet
CHANGED
@@ -9,22 +9,23 @@ WARN = Logger::WARN
|
|
9
9
|
FATAL = Logger::FATAL
|
10
10
|
INFO = Logger::INFO
|
11
11
|
|
12
|
+
client_type = ARGV[0]
|
13
|
+
|
14
|
+
unless ["ec2","autoscale","-h"].include? client_type
|
15
|
+
Rivet::Utils.die "You must select either 'ec2' or 'autoscale' your first argument"
|
16
|
+
end
|
17
|
+
|
12
18
|
# Default option values
|
13
19
|
options = OpenStruct.new
|
14
20
|
options.log_level = INFO
|
15
21
|
options.profile = 'default'
|
16
|
-
options.config_path = File.join('.',
|
22
|
+
options.config_path = File.join('.', client_type)
|
17
23
|
|
18
24
|
OptionParser.new do |o|
|
19
|
-
o.on('-g', '--group [GROUP_NAME]', String, 'Autoscaling group name') do |g|
|
20
|
-
options.group = g
|
21
|
-
end
|
22
|
-
|
23
25
|
o.on('-l', '--log-level [LEVEL]', String, 'specify the log level (default is INFO)') do |l|
|
24
26
|
options.log_level = Kernel.const_get l.upcase
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
29
|
o.on('-p', '--profile [PROFILE_NAME]', 'Selects the AWS profile to use (default is "default")') do |p|
|
29
30
|
options.profile = p
|
30
31
|
end
|
@@ -33,11 +34,15 @@ OptionParser.new do |o|
|
|
33
34
|
options.sync = s
|
34
35
|
end
|
35
36
|
|
36
|
-
o.on('-c', '--config-path [PATH]', 'The configuration path to use (default is ./autoscale)') do |c|
|
37
|
+
o.on('-c', '--config-path [PATH]', 'The configuration path to use (default is ./autoscale or ./ec2)') do |c|
|
37
38
|
options.config_path = c
|
38
39
|
end
|
39
40
|
|
40
|
-
o.on('-
|
41
|
+
o.on('-n', '--name [NAME]', String, 'Server or Autoscaling group name') do |n|
|
42
|
+
options.name = n
|
43
|
+
end
|
44
|
+
|
45
|
+
o.on('-h') { Rivet::Log.info o; exit 0 }
|
41
46
|
|
42
47
|
begin
|
43
48
|
o.parse!
|
@@ -48,5 +53,5 @@ OptionParser.new do |o|
|
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
51
|
-
Rivet::Client.new.run(options)
|
56
|
+
Rivet::Client.new.run(client_type,options)
|
52
57
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
|
3
4
|
module Rivet
|
4
5
|
class Autoscale
|
5
6
|
|
@@ -56,7 +57,7 @@ module Rivet
|
|
56
57
|
!differences.empty?
|
57
58
|
end
|
58
59
|
|
59
|
-
def
|
60
|
+
def display(level = 'info')
|
60
61
|
Rivet::Log.write(level, 'Remote and local match') unless differences?
|
61
62
|
differences.each_pair do |attr, values|
|
62
63
|
Rivet::Log.write(level, "#{attr}:")
|
@@ -64,13 +65,25 @@ module Rivet
|
|
64
65
|
Rivet::Log.write(level, " local: #{values[:local]}")
|
65
66
|
end
|
66
67
|
Rivet::Log.write('debug', @launch_config.user_data)
|
68
|
+
display_lc_diff
|
69
|
+
end
|
70
|
+
|
71
|
+
def display_lc_diff
|
72
|
+
@lc_diff ||= get_lc_diff
|
73
|
+
|
74
|
+
Rivet::Log.info"Displaying diff for launch configuration:"
|
75
|
+
@lc_diff.each do |d|
|
76
|
+
d.each do |current|
|
77
|
+
Rivet::Log.info " #{current.action} #{current.element.join}"
|
78
|
+
end
|
79
|
+
end
|
67
80
|
end
|
68
81
|
|
69
82
|
def sync
|
70
83
|
if differences?
|
71
84
|
Rivet::Log.info "Syncing autoscale group changes to AWS for #{@name}"
|
72
85
|
autoscale = AWS::AutoScaling.new
|
73
|
-
group
|
86
|
+
group = autoscale.groups[@name]
|
74
87
|
|
75
88
|
@launch_config.save
|
76
89
|
create(options) unless group.exists?
|
@@ -97,7 +110,7 @@ module Rivet
|
|
97
110
|
|
98
111
|
OPTIONS.each do |o|
|
99
112
|
remote_value = @remote_group.send(o)
|
100
|
-
local_value
|
113
|
+
local_value = send(o)
|
101
114
|
|
102
115
|
if (remote_value != local_value)
|
103
116
|
differences[o] = { :local => send(o), :remote => @remote_group.send(o) }
|
@@ -106,6 +119,23 @@ module Rivet
|
|
106
119
|
differences
|
107
120
|
end
|
108
121
|
|
122
|
+
def get_lc_diff
|
123
|
+
autoscale = AWS::AutoScaling.new
|
124
|
+
remote_lc_identity = @remote_group.launch_configuration
|
125
|
+
|
126
|
+
if remote_lc_identity.nil?
|
127
|
+
remote_user_data = ''
|
128
|
+
else
|
129
|
+
remote_lc = autoscale.launch_configurations[remote_lc_identity]
|
130
|
+
remote_user_data = remote_lc.user_data.split("\n")
|
131
|
+
end
|
132
|
+
|
133
|
+
# We split on new lines so the diff doesn't compare by character
|
134
|
+
local_user_data = @launch_config.user_data.split("\n")
|
135
|
+
|
136
|
+
Diff::LCS.diff(remote_user_data,local_user_data)
|
137
|
+
end
|
138
|
+
|
109
139
|
def get_update_options
|
110
140
|
options = {}
|
111
141
|
|
@@ -123,7 +153,6 @@ module Rivet
|
|
123
153
|
end
|
124
154
|
|
125
155
|
def create(options)
|
126
|
-
|
127
156
|
# When creating an autoscaling group passing empty arrays for subnets
|
128
157
|
# or some other fields can cause it to barf. Remove them first.
|
129
158
|
options.delete_if { |k, v| v.respond_to?(:'empty?') && v.empty? }
|
@@ -1,21 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Rivet
|
4
|
-
class
|
5
|
-
attr_reader :name
|
6
|
-
attr_accessor :bootstrap
|
7
|
-
|
8
|
-
def self.from_file(dsl_file, load_path='.')
|
9
|
-
name = File.basename(dsl_file, '.rb')
|
10
|
-
data = Proc.new { eval(File.read(dsl_file)) }
|
11
|
-
new(name, load_path, &data)
|
12
|
-
end
|
4
|
+
class AutoscaleConfig < BaseConfig
|
13
5
|
|
14
6
|
def initialize(name, load_path='.', &block)
|
15
|
-
super()
|
16
|
-
@name = name
|
17
|
-
@path = load_path
|
18
|
-
@bootstrap = OpenState.new
|
19
7
|
@required_fields = {
|
20
8
|
:min_size => nil,
|
21
9
|
:max_size => nil,
|
@@ -28,25 +16,13 @@ module Rivet
|
|
28
16
|
:tags => [],
|
29
17
|
:termination_policies => ['Default']
|
30
18
|
}
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def path(*args)
|
35
|
-
if args.size < 1
|
36
|
-
@path
|
37
|
-
else
|
38
|
-
File.join(@path, *args)
|
39
|
-
end
|
19
|
+
super(name,load_path, &block)
|
40
20
|
end
|
41
21
|
|
42
22
|
def normalize_availability_zones
|
43
23
|
availability_zones.map { |zone| region + zone }.sort
|
44
24
|
end
|
45
25
|
|
46
|
-
def normalize_security_groups
|
47
|
-
security_groups.sort
|
48
|
-
end
|
49
|
-
|
50
26
|
def normalize_load_balancers
|
51
27
|
load_balancers.sort
|
52
28
|
end
|
@@ -75,13 +51,7 @@ module Rivet
|
|
75
51
|
end
|
76
52
|
normalized_tags << normalized_hash
|
77
53
|
end
|
78
|
-
normalized_tags
|
79
|
-
end
|
80
|
-
|
81
|
-
protected
|
82
|
-
|
83
|
-
def import(import_path)
|
84
|
-
lambda { eval(File.read(import_path)) }.call
|
54
|
+
normalized_tags.sort_by { |h| h[:key] }
|
85
55
|
end
|
86
56
|
end
|
87
57
|
end
|
@@ -5,18 +5,11 @@ module Rivet
|
|
5
5
|
|
6
6
|
ATTRIBUTES = [
|
7
7
|
:bootstrap,
|
8
|
-
:iam_instance_profile,
|
9
|
-
:image_id,
|
10
|
-
:instance_type,
|
11
|
-
:key_name,
|
12
|
-
:security_groups,
|
13
|
-
:associate_public_ip_address,
|
14
8
|
:detailed_instance_monitoring,
|
15
|
-
:block_device_mappings,
|
16
|
-
:kernel_id,
|
17
|
-
:ramdisk_id,
|
18
9
|
:spot_price
|
19
|
-
]
|
10
|
+
] + BASE_AWS_ATTRIBUTES
|
11
|
+
|
12
|
+
ATTRIBUTES.each { |a| attr_reader a }
|
20
13
|
|
21
14
|
attr_reader :id_prefix, :config
|
22
15
|
|
@@ -71,7 +64,11 @@ module Rivet
|
|
71
64
|
def build_identity_string
|
72
65
|
identity = ATTRIBUTES.inject('') do |accum, attribute|
|
73
66
|
if attribute != :bootstrap
|
74
|
-
attr_value = self.send(attribute)
|
67
|
+
attr_value = if self.send(attribute).nil?
|
68
|
+
"\0"
|
69
|
+
else
|
70
|
+
self.send(attribute)
|
71
|
+
end
|
75
72
|
attr_value = attr_value.join("\t") if attr_value.respond_to? :join
|
76
73
|
attr_value = attr_value.to_s if !!attr_value == attr_value
|
77
74
|
accum << attribute.to_s
|