rivet 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Excludes:
3
+ - autoscale/**
4
+ - example/**
5
+ - example/autoscale/**
6
+
7
+ Eval:
8
+ Enabled: false
9
+
10
+ LineLength:
11
+ Enabled: false
12
+
13
+ HashSyntax:
14
+ Enabled: false
15
+
16
+ MethodLength:
17
+ Max: 25
18
+
data/.travis.yml CHANGED
@@ -1,13 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
4
6
  - rbx-2.1.1
5
- - rbx-head
7
+ - rbx-2.2.5
6
8
  - jruby-head
7
9
  before_install:
8
- - rvm get head; rvm use $TRAVIS_RUBY_VERSION --install --binary --fuzzy --debug
9
10
  - gem install bundler
10
- matrix:
11
- allow_failures:
12
- - rvm: rbx-head
13
11
 
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  Rivet CHANGELOG
2
2
  ===
3
3
 
4
+ 2.0.0 -
5
+ ---
6
+ * Completely rewrite of the configuration system to use a DSL instead of YAML
7
+ * Complete overhaul of how generating bootstrap data works. A user now provides
8
+ any arbitrary options they please and a template to use. Rivet will simply
9
+ render the template with the provided options.
10
+
4
11
  1.4.0 - Released 11/22/13
5
12
  ---
6
13
  * Adds functionality to apply an elastic_ip durning bootstrap
data/Gemfile.lock CHANGED
@@ -1,27 +1,29 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- aws-sdk (1.24.0)
4
+ aws-sdk (1.33.0)
5
5
  json (~> 1.4)
6
- nokogiri (>= 1.4.4, < 1.6.0)
6
+ nokogiri (>= 1.4.4)
7
7
  uuidtools (~> 2.1)
8
8
  diff-lcs (1.2.5)
9
9
  ffi2-generators (0.1.1)
10
10
  json (1.8.1)
11
11
  json (1.8.1-java)
12
- minitest (4.7.5)
13
- nokogiri (1.5.10)
14
- nokogiri (1.5.10-java)
15
- rake (10.1.0)
12
+ mini_portile (0.5.2)
13
+ nokogiri (1.6.1)
14
+ mini_portile (~> 0.5.0)
15
+ nokogiri (1.6.1-java)
16
+ mini_portile (~> 0.5.0)
17
+ rake (10.1.1)
16
18
  rspec (2.14.1)
17
19
  rspec-core (~> 2.14.0)
18
20
  rspec-expectations (~> 2.14.0)
19
21
  rspec-mocks (~> 2.14.0)
20
22
  rspec-core (2.14.7)
21
- rspec-expectations (2.14.4)
23
+ rspec-expectations (2.14.5)
22
24
  diff-lcs (>= 1.1.3, < 2.0)
23
- rspec-mocks (2.14.4)
24
- rubysl (2.0.12)
25
+ rspec-mocks (2.14.5)
26
+ rubysl (2.0.15)
25
27
  rubysl-abbrev (~> 2.0)
26
28
  rubysl-base64 (~> 2.0)
27
29
  rubysl-benchmark (~> 2.0)
@@ -56,7 +58,6 @@ GEM
56
58
  rubysl-io-wait (~> 2.0)
57
59
  rubysl-ipaddr (~> 2.0)
58
60
  rubysl-irb (~> 2.0)
59
- rubysl-json (~> 2.0)
60
61
  rubysl-logger (~> 2.0)
61
62
  rubysl-mathn (~> 2.0)
62
63
  rubysl-matrix (~> 2.0)
@@ -89,7 +90,6 @@ GEM
89
90
  rubysl-resolv (~> 2.0)
90
91
  rubysl-rexml (~> 2.0)
91
92
  rubysl-rinda (~> 2.0)
92
- rubysl-ripper (~> 2.0)
93
93
  rubysl-rss (~> 2.0)
94
94
  rubysl-scanf (~> 2.0)
95
95
  rubysl-securerandom (~> 2.0)
@@ -102,13 +102,11 @@ GEM
102
102
  rubysl-sync (~> 2.0)
103
103
  rubysl-syslog (~> 2.0)
104
104
  rubysl-tempfile (~> 2.0)
105
- rubysl-test-unit (~> 2.0)
106
105
  rubysl-thread (~> 2.0)
107
106
  rubysl-thwait (~> 2.0)
108
107
  rubysl-time (~> 2.0)
109
108
  rubysl-timeout (~> 2.0)
110
109
  rubysl-tmpdir (~> 2.0)
111
- rubysl-tracer (~> 2.0)
112
110
  rubysl-tsort (~> 2.0)
113
111
  rubysl-un (~> 2.0)
114
112
  rubysl-uri (~> 2.0)
@@ -117,36 +115,36 @@ GEM
117
115
  rubysl-xmlrpc (~> 2.0)
118
116
  rubysl-yaml (~> 2.0)
119
117
  rubysl-zlib (~> 2.0)
120
- rubysl-abbrev (2.0.2)
118
+ rubysl-abbrev (2.0.4)
121
119
  rubysl-base64 (2.0.0)
122
- rubysl-benchmark (2.0.0)
120
+ rubysl-benchmark (2.0.1)
123
121
  rubysl-bigdecimal (2.0.2)
124
- rubysl-cgi (2.0.0)
125
- rubysl-cgi-session (2.0.0)
122
+ rubysl-cgi (2.0.1)
123
+ rubysl-cgi-session (2.0.1)
126
124
  rubysl-cmath (2.0.0)
127
125
  rubysl-complex (2.0.0)
128
126
  rubysl-continuation (2.0.0)
129
127
  rubysl-coverage (2.0.3)
130
- rubysl-csv (2.0.1)
128
+ rubysl-csv (2.0.2)
131
129
  rubysl-english (~> 2.0)
132
- rubysl-curses (2.0.0)
130
+ rubysl-curses (2.0.1)
133
131
  rubysl-date (2.0.6)
134
- rubysl-delegate (2.0.0)
132
+ rubysl-delegate (2.0.1)
135
133
  rubysl-digest (2.0.3)
136
134
  rubysl-drb (2.0.1)
137
135
  rubysl-e2mmap (2.0.0)
138
136
  rubysl-english (2.0.0)
139
137
  rubysl-enumerator (2.0.0)
140
- rubysl-erb (2.0.0)
138
+ rubysl-erb (2.0.1)
141
139
  rubysl-etc (2.0.3)
142
140
  ffi2-generators (~> 0.1)
143
141
  rubysl-expect (2.0.0)
144
142
  rubysl-fcntl (2.0.4)
145
143
  ffi2-generators (~> 0.1)
146
144
  rubysl-fiber (2.0.0)
147
- rubysl-fileutils (2.0.2)
148
- rubysl-find (2.0.0)
149
- rubysl-forwardable (2.0.0)
145
+ rubysl-fileutils (2.0.3)
146
+ rubysl-find (2.0.1)
147
+ rubysl-forwardable (2.0.1)
150
148
  rubysl-getoptlong (2.0.0)
151
149
  rubysl-gserver (2.0.0)
152
150
  rubysl-socket (~> 2.0)
@@ -155,13 +153,11 @@ GEM
155
153
  rubysl-io-nonblock (2.0.0)
156
154
  rubysl-io-wait (2.0.0)
157
155
  rubysl-ipaddr (2.0.0)
158
- rubysl-irb (2.0.3)
156
+ rubysl-irb (2.0.4)
159
157
  rubysl-e2mmap (~> 2.0)
160
158
  rubysl-mathn (~> 2.0)
161
159
  rubysl-readline (~> 2.0)
162
160
  rubysl-thread (~> 2.0)
163
- rubysl-tracer (~> 2.0)
164
- rubysl-json (2.0.2)
165
161
  rubysl-logger (2.0.0)
166
162
  rubysl-mathn (2.0.0)
167
163
  rubysl-matrix (2.1.0)
@@ -185,13 +181,13 @@ GEM
185
181
  rubysl-observer (2.0.0)
186
182
  rubysl-open-uri (2.0.0)
187
183
  rubysl-open3 (2.0.0)
188
- rubysl-openssl (2.0.3)
184
+ rubysl-openssl (2.1.0)
189
185
  rubysl-optparse (2.0.1)
190
186
  rubysl-shellwords (~> 2.0)
191
187
  rubysl-ostruct (2.0.4)
192
188
  rubysl-pathname (2.0.0)
193
189
  rubysl-prettyprint (2.0.2)
194
- rubysl-prime (2.0.0)
190
+ rubysl-prime (2.0.1)
195
191
  rubysl-profile (2.0.0)
196
192
  rubysl-profiler (2.0.1)
197
193
  rubysl-pstore (2.0.0)
@@ -200,8 +196,7 @@ GEM
200
196
  rubysl-readline (2.0.2)
201
197
  rubysl-resolv (2.0.0)
202
198
  rubysl-rexml (2.0.2)
203
- rubysl-rinda (2.0.0)
204
- rubysl-ripper (2.0.0)
199
+ rubysl-rinda (2.0.1)
205
200
  rubysl-rss (2.0.0)
206
201
  rubysl-scanf (2.0.0)
207
202
  rubysl-securerandom (2.0.0)
@@ -215,14 +210,11 @@ GEM
215
210
  rubysl-syslog (2.0.1)
216
211
  ffi2-generators (~> 0.1)
217
212
  rubysl-tempfile (2.0.1)
218
- rubysl-test-unit (2.0.1)
219
- minitest (~> 4.7)
220
213
  rubysl-thread (2.0.2)
221
214
  rubysl-thwait (2.0.0)
222
215
  rubysl-time (2.0.3)
223
216
  rubysl-timeout (2.0.0)
224
217
  rubysl-tmpdir (2.0.0)
225
- rubysl-tracer (2.0.0)
226
218
  rubysl-tsort (2.0.1)
227
219
  rubysl-un (2.0.0)
228
220
  rubysl-fileutils (~> 2.0)
@@ -231,7 +223,7 @@ GEM
231
223
  rubysl-weakref (2.0.0)
232
224
  rubysl-webrick (2.0.0)
233
225
  rubysl-xmlrpc (2.0.0)
234
- rubysl-yaml (2.0.3)
226
+ rubysl-yaml (2.0.4)
235
227
  rubysl-zlib (2.0.1)
236
228
  uuidtools (2.1.4)
237
229
 
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Rivet
4
4
  =======
5
- Rivet enables you to describe autoscaling groups and their launch configurations as yaml. You can then sync those changes to Amazon Web Services (AWS.)
5
+ Rivet enables you to describe autoscaling groups and their launch configurations as configuration. You can then sync those changes to Amazon Web Services (AWS.)
6
6
 
7
- You provide a template and it's options to render as user-data for your launch configurations to build a bootstrap script for chef, installed via gems.
7
+ You optionally provide a template and it's options to render as user-data for your launch configurations.
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.
@@ -56,59 +56,85 @@ Autoscaling group definition directories and files
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 ./autoscale by default) for some definitions. It expects autoscale groups to have a directory named for them
60
- with a conf.yml inside of it as well as a defaults.yml in whatever directory you use for your autoscaling group definitions.
59
+ Rivet will look in the directory specified on the command line (or ./autoscale by default) for configuration files. It expects the configuration file name to match the name of the autoscaling group.
61
60
 
62
61
  ```
63
62
  ./autoscale
64
- `- defaults.yml
65
- `- <autoscale group name>
66
- `- conf.yml
63
+ `- group_name.rb
67
64
  ```
68
65
 
69
- defaults.yml and conf.yml both accept all the same options. A groups definition will be deep merged over the defaults.
70
-
71
- The yaml file format:
72
-
73
- ```yaml
74
- min_size: SIZE <integer>
75
- max_size: SIZE <integer>
76
- region: AWS_REGION <string>
77
- availability_zones: [ZONE<string>,ZONE...]
78
- iam_instance_profile: INSTANCE_PROFILE <string>
79
- tags:
80
- -
81
- key: KEY_NAME<string>
82
- value: KEY_VALUE<string>
83
- -
84
- key: KEY_NAME<string>
85
- value: KEY_VALUE<string>
86
-
87
- bootstrap:
88
- chef_command: CHEF_COMMAND <string>
89
- chef_organization: CHEF_ORGANIZATION <string>
90
- chef_username: CHEF_USERNAME <string>
91
- template: TEMPLATE <string>
92
- config_dir: CONFIGURATION_FILES_DIR <string>
93
- environment: CHEF_ENVIRONMENT <string>
94
- region: AWS_REGION <string>
95
- name: NAME <string>
96
- elastic_ip: AWS_ELASTIC_IP <string>
97
- gems:
98
- - [GEM_NAME<string>,GEM_VERSION<string>]
99
- - [GEM_NAME<string>]
100
- run_list:
101
- - 'role[example]' <string>
66
+ Configuration DSL
67
+ -------------------------
68
+
69
+ You can execute any arbitrary ruby you please inside of a rivet configuration.
70
+
71
+ Rivets built in commands:
72
+
73
+ path()
74
+
75
+ - A function that returns the configuration directory path.
76
+ - optionally takes any number of strings as arguments and will return the configuration
77
+ path with those strings joined to it.
78
+
79
+ import(PATH)
80
+
81
+ - A function that allows you to import other rivet configuration files
82
+
83
+ bootstrap
84
+
85
+ - provide this with a template file and a set of variables. The variables will
86
+ be made available to the template file provided. Rendered, and injected as EC2
87
+ user-data.
88
+
89
+ Rivet will only use the following attributes.
90
+
91
+ ```
92
+ min_size INTEGER <required>
93
+ max_size INTEGER <required>
94
+ desired_capacity INTEGER <optional, default 0)
95
+ region STRING <required>
96
+ availability_zones ARRAY <required>
97
+ default_cooldown INTEGER <optional, default 300)
98
+ health_check_grace_period INTEGER <optional, default 0)
99
+ health_check_type SYMBOL <optional, default :ec2)
100
+ load_balancers ARRAY <optional, default nil)
101
+ subnet ARRAY <optional, default nil)
102
+ iam_instance_profile STRING <optional, default nil)
103
+ tags ARRAY <optional, default nil)
102
104
 
103
105
  ```
104
106
 
105
- Availability zones should use the single character of the zone. The region will be appended by rivet.
107
+ Availability zones should use the single character of the zone ('a', 'b','c'). The region will be appended by rivet.
108
+
109
+ Tags should be an Array of Hashes with the format:
110
+ { key: String,
111
+ value: String,
112
+ propogate_at_launch: True/False <optional, default True>'}
113
+
114
+
115
+ Using the bootstrap functionality
116
+ ---------------------------------
117
+
118
+ Rivet allows you to provide it with an ERB template as well as any number of variables to make
119
+ available to that template. This will be rendered as user-data for the launch configuration.
120
+
121
+ The following attribute is required
122
+
123
+ bootstrap.template <some_path_to_a_template>
124
+
125
+ You may also provide any number of your own variables to use in the template
126
+
127
+ ```
128
+ bootstrap.my_var "yellow"
129
+ bootstrap.number_of_elves 4
130
+ ```
106
131
 
107
- The following files should exist in the configuration directory specified under the bootstrap -> config_dir key:
132
+ Rivet will pass a binding to the template such that you can access these options
133
+ without prepending bootstrap to them.
108
134
 
109
- * A template file (specified by the bootstrap -> template file name)
110
- * A validator pem (named by the bootstrap -> environment key as <environment>-validator.pem)
135
+ For example
111
136
 
137
+ `<%= my_var %>` in your template will render the string 'yellow'.
112
138
 
113
139
  Usage
114
140
  =====
@@ -119,8 +145,7 @@ Usage: rivet [options]
119
145
  -l, --log-level [LEVEL] specify the log level (default is INFO)
120
146
  -p, --profile [PROFILE_NAME] Selects the AWS profile to use (default is 'default')
121
147
  -s, --sync Sync the changes remotely to AWS
122
- -d [PATH], The autoscale definitions directory to use (default is ./autoscale)
123
- --definitions-directory
148
+ -c, --config-path [PATH] The autoscale config path to use (default is ./autoscale)
124
149
  -h
125
150
  ```
126
151
 
@@ -0,0 +1,23 @@
1
+ region 'us-west-2'
2
+ availability_zones %w(a b c)
3
+ key_name 'ProdWest20130503'
4
+ instance_type 'm1.xlarge'
5
+ image_id 'ami-d3ce5ee3'
6
+
7
+ bootstrap.template path('default.erb')
8
+ bootstrap.chef_command '/usr/bin/chef-client -j /etc/chef/first-boot.json -L /root/first_run.log -E prodwest'
9
+ bootstrap.chef_organization 'cmwest'
10
+ bootstrap.chef_username 'ops_prodwest_cm'
11
+ bootstrap.environment 'prodwest'
12
+ bootstrap.region region
13
+ bootstrap.gems 'httparty' => '0.11.0',
14
+ 'net-ssh' => '2.2.2',
15
+ 'net-ssh-gateway' => '1.1.0',
16
+ 'net-ssh-multi' => '1.1',
17
+ 'json' => '1.7.6',
18
+ 'hipchat' => '0.12.0',
19
+ 'rake' => '10.0.4',
20
+ 'bundler' => '1.3.5',
21
+ 'aws-sdk' => '1.30.0',
22
+ 'ohai' => '6.20.0',
23
+ 'chef' => '11.8.0'
data/bin/rivet CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
 
3
- $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
4
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
5
  require 'rivet'
5
- require 'rivet/client'
6
6
 
7
7
  DEBUG = Logger::DEBUG
8
8
  WARN = Logger::WARN
@@ -10,39 +10,43 @@ FATAL = Logger::FATAL
10
10
  INFO = Logger::INFO
11
11
 
12
12
  # Default option values
13
- options = {
14
- :log_level => INFO,
15
- :profile => 'default',
16
- :definitions_directory => './autoscale'
17
- }
13
+ options = OpenStruct.new
14
+ options.log_level = INFO
15
+ options.profile = 'default'
16
+ options.config_path = File.join('.', 'autoscale')
18
17
 
19
18
  OptionParser.new do |o|
20
19
  o.on('-g', '--group [GROUP_NAME]', String, 'Autoscaling group name') do |g|
21
- options[:group] = g
20
+ options.group = g
22
21
  end
23
22
 
24
- o.on('-l', '--log-level [LEVEL]', String, "specify the log level (default is INFO)") do |l|
25
- options[:log_level] = Kernel.const_get l.upcase
23
+ o.on('-l', '--log-level [LEVEL]', String, 'specify the log level (default is INFO)') do |l|
24
+ options.log_level = Kernel.const_get l.upcase
26
25
  end
27
26
 
28
27
 
29
- o.on('-p', '--profile [PROFILE_NAME]', "Selects the AWS profile to use (default is 'default')") do |p|
30
- options[:profile] = p
28
+ o.on('-p', '--profile [PROFILE_NAME]', 'Selects the AWS profile to use (default is "default")') do |p|
29
+ options.profile = p
31
30
  end
32
31
 
33
- o.on('-s', '--sync', "Sync the changes remotely to AWS") do |s|
34
- options[:sync] = s
32
+ o.on('-s', '--sync', 'Sync the changes remotely to AWS') do |s|
33
+ options.sync = s
35
34
  end
36
35
 
37
- o.on('-d', '--definitions-directory [PATH]', "The autoscale definitions directory to use (default is ./autoscale)") do |d|
38
- options[:definitions_directory] = d
36
+ o.on('-c', '--config-path [PATH]', 'The configuration path to use (default is ./autoscale)') do |c|
37
+ options.config_path = c
39
38
  end
40
39
 
41
- o.on('-h') { puts o; exit }
42
- o.parse!
43
- end
40
+ o.on('-h') { Rivet::Log.info o; exit }
44
41
 
45
- raise "--group [GROUP_NAME] argument is required!" if options[:group].nil?
42
+ begin
43
+ o.parse!
44
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
45
+ Rivet::Log.fatal $!.to_s
46
+ Rivet::Log.fatal o
47
+ exit 255
48
+ end
49
+ end
46
50
 
47
51
  Rivet::Client.new.run(options)
48
52
 
@@ -0,0 +1,22 @@
1
+ min_size 0
2
+ max_size 0
3
+ desired_capacity 0
4
+ region 'us-east-2'
5
+ availability_zones %w(a b c)
6
+ key_name 'YourKeyName'
7
+ instance_type 'm1.large'
8
+ security_groups ['group1','group2']
9
+ image_id 'ami-1234567'
10
+ iam_instance_profile 'some_iam_profile'
11
+
12
+ bootstrap.chef_organization 'YourChefOrg'
13
+ bootstrap.chef_command '/usr/bin/chef-client -j /etc/chef/first-boot.json -L /root/first_run.log'
14
+ bootstrap.template 'default.erb'
15
+ bootstrap.environment 'ChefEnvironment'
16
+ bootstrap.gems [
17
+ { rake: '10.0.4' }
18
+ { ohai: '6.16.0' }
19
+ { chef: '11.6.0' }
20
+ ]
21
+ bootstrap.run_list [ 'role[some_chef_role]' ]
22
+
@@ -0,0 +1,10 @@
1
+ import path('defaults.rb')
2
+
3
+ min_size 1
4
+ max_size 3
5
+ desired_capacity 2
6
+ region 'us-west-2'
7
+ tags [ { key: 'Name', value: 'Value' } ]
8
+
9
+ bootstrap.run_list [ 'role[example]' ]
10
+