rivet 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Rivet CHANGELOG
2
2
  ===
3
3
 
4
+ 1.2.0 - Released 11/18/13
5
+ ---
6
+ * Adds functionality to apply tags to autoscaling groups
7
+ * Updates Rivet to handle the new AWS CLI config file format (profiles now include the world profile in them)
8
+
4
9
  1.1.0 - Released 11/12/13
5
10
  ---
6
11
  * Rivet no allows you to specify a directory with the -d [--definitions-directory] option
data/README.md CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Rivet
4
4
  =======
5
- Rivet is a small utility which allows you to describe an autoscaling groups and it's launch configurations as yaml. You can then sync those changes to AWS.
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.)
6
6
 
7
- Rivet allows you to provide a template and it's options which will be rendered as user-data for your launch configurations. It is currently opinionated and assumes you are trying to build
8
- a bootstrap script for chef installed via gems. You can of course provide it with any template you desire, and in future releases this system will become more flexible and less opinionated.
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.
9
8
 
10
- Rivet is also opinionated about how it names launch configurations, as it generates unique deterministic names for them and automatically assigns the proper launch configuration to your
9
+ Rivet generates unique deterministic names for launch configurations and automatically assigns the proper launch configuration to your
11
10
  autoscaling group based upon it's generated identity.
12
11
 
12
+
13
13
  Installation
14
14
  ============
15
15
 
16
- gem install rivet
16
+ `gem install rivet`
17
17
 
18
18
  Setup
19
19
  =====
@@ -25,16 +25,16 @@ Rivet uses the python AWS CLI tools [https://github.com/aws/aws-cli] configurati
25
25
 
26
26
  Right now Rivet only uses the following options from the file:
27
27
 
28
- * profile name
29
- * aws\_access\_key\_id
30
- * aws\_secret\_access\_key
31
- * region
28
+ * `profile name`
29
+ * `aws_access_key_id`
30
+ * `aws_secret_access_key`
31
+ * `region`
32
32
 
33
33
  An example config could look as follows:
34
34
 
35
- ```
35
+ ```ini
36
36
  [default]
37
- aws_access_key_id<YOUR ACCESS KEY ID>
37
+ aws_access_key_id=<YOUR ACCESS KEY ID>
38
38
  aws_secret_access_key=<YOUR SECRET ACCESS KEY>
39
39
  region=us-east-1
40
40
 
@@ -44,9 +44,9 @@ aws_secret_access_key=<YOUR SECRET_ACCESS KEY>
44
44
  region=us-west-2
45
45
  ```
46
46
 
47
- Alternatively you can specify your AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY as environment variables.
47
+ Alternatively you can specify your `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` as environment variables.
48
48
 
49
- You will still need to specify the region to use in your AWS\_CONFIG\_FILE.
49
+ You will still need to specify the region to use in your `AWS_CONFIG_FILE`.
50
50
 
51
51
  Rivet will use the [default] profile if you do not specify a profile to use with the -p [--profile] option.
52
52
 
@@ -56,20 +56,21 @@ 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
- You should create an "autoscale" directory wherever you plan to run rivet from. Currently it always looks in the current directory for definition files. It expects a directory structure as such.
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.
60
61
 
61
62
  ```
62
63
  ./autoscale
63
- | - defaults.yml
64
- | - <autoscale group name>
65
- | - conf.yml
64
+ `- defaults.yml
65
+ `- <autoscale group name>
66
+ `- conf.yml
66
67
  ```
67
68
 
68
69
  defaults.yml and conf.yml both accept all the same options. A groups definition will be deep merged over the defaults.
69
70
 
70
71
  The yaml file format:
71
72
 
72
- ```
73
+ ```yaml
73
74
  min_size: SIZE <integer>
74
75
  max_size: SIZE <integer>
75
76
  region: AWS REGION <STRING>
@@ -93,8 +94,8 @@ Availability zones should use the single character of the zone. The region will
93
94
 
94
95
  The following files should exist in the configuration directory specified under the bootstrap -> config_dir key:
95
96
 
96
- A template file (specified by the bootstrap -> template file name)
97
- A validator pem (named by the bootstrap -> environment key as <environment>-validator.pem)
97
+ * A template file (specified by the bootstrap -> template file name)
98
+ * A validator pem (named by the bootstrap -> environment key as <environment>-validator.pem)
98
99
 
99
100
 
100
101
  Usage
@@ -106,22 +107,24 @@ Usage: rivet [options]
106
107
  -l, --log-level [LEVEL] specify the log level (default is INFO)
107
108
  -p, --profile [PROFILE_NAME] Selects the AWS profile to use (default is 'default')
108
109
  -s, --sync Sync the changes remotely to AWS
110
+ -d [PATH], The autoscale definitions directory to use (default is ./autoscale)
111
+ --definitions-directory
109
112
  -h
110
113
  ```
111
114
 
112
- Using rivet to check the differences for the example_group autoscaling group
115
+ check the differences for the example_group autoscaling group
113
116
 
114
117
  ```bash
115
118
  rivet -g example_group
116
119
  ```
117
120
 
118
- Using rivet to check the differences for the example_group using the foobar profile
121
+ check the differences for the example_group using the foobar profile
119
122
 
120
123
  ```bash
121
124
  rivet -g example_group -p foobar
122
125
  ```
123
126
 
124
- Using rivet to sync the differences for the example_group using the foobar profile
127
+ sync the differences for the example_group using the foobar profile
125
128
 
126
129
  ```bash
127
130
  rivet -g example_group -p foobar -s
@@ -3,12 +3,24 @@ module Rivet
3
3
 
4
4
  REQUIRED_FIELDS = [:min_size,:max_size,:launch_configuration,:availability_zones]
5
5
 
6
- attr_reader :min_size, :max_size, :name, :launch_configuration, :availability_zones
6
+ attr_reader :min_size, :max_size, :name, :launch_configuration
7
+ attr_reader :availability_zones, :tags
7
8
 
8
9
  def initialize(name,definition)
9
10
  @name = name
10
11
  @min_size = definition['min_size']
11
12
  @max_size = definition['max_size']
13
+
14
+ if definition.has_key?('tags')
15
+ definition['tags'].each do |t|
16
+ unless t.has_key?('propagate_at_launch')
17
+ t['propagate_at_launch'] = true
18
+ end
19
+ end
20
+ @tags = definition['tags']
21
+ else
22
+ @tags = Array.new
23
+ end
12
24
  @launch_config = LaunchConfig.new(definition)
13
25
 
14
26
  # Normalizing zones to match what the SDK expects, E.G. "<region><zone>"
@@ -53,6 +65,9 @@ module Rivet
53
65
  @launch_config.save
54
66
  create(options) unless group.exists?
55
67
 
68
+ Rivet::Log.debug("Updating autoscaling group with the follow options")
69
+ Rivet::Log.debug(options.inspect)
70
+
56
71
  group.update(options)
57
72
  else
58
73
  Rivet::Log.info("No autoscale differences to sync to AWS for #{@name}.")
@@ -78,7 +93,7 @@ module Rivet
78
93
  def get_differences
79
94
  remote = get_remote
80
95
  differences = Hash.new
81
- [:min_size,:max_size,:launch_configuration].each do |a|
96
+ [:min_size,:max_size,:launch_configuration,:tags].each do |a|
82
97
  if remote[a.to_s] != self.send(a)
83
98
  differences[a.to_s] = { 'remote' => remote[a.to_s], 'local' => self.send(a) }
84
99
  end
@@ -91,6 +106,8 @@ module Rivet
91
106
  differences
92
107
  end
93
108
 
109
+ protected
110
+
94
111
  def get_remote
95
112
  autoscale = AWS::AutoScaling.new()
96
113
  remote_group = autoscale.groups[@name]
@@ -101,6 +118,11 @@ module Rivet
101
118
  accum
102
119
  end
103
120
 
121
+ # {:resource_id=>"venus", :propagate_at_launch=>true, :value=>"Venus", :key=>"Name", :resource_type=>"auto-scaling-group"}
122
+ remote_hash['tags'] = remote_group.tags.to_a.inject(Array.new) do |tags,current|
123
+ tags << normalize_tag(current)
124
+ end
125
+
104
126
  remote_hash['launch_configuration'] = remote_group.launch_configuration_name
105
127
 
106
128
  # Normalize their AWS::Core::Data::List to a sorted array
@@ -121,5 +143,15 @@ module Rivet
121
143
  end
122
144
  end
123
145
 
146
+ def normalize_tag(tag)
147
+ normalized_tag = Hash.new
148
+ tag.each_pair do |k,v|
149
+ unless (k == :resource_id || k == :resource_type)
150
+ normalized_tag[k.to_s] = v
151
+ end
152
+ end
153
+ normalized_tag
154
+ end
155
+
124
156
  end
125
157
  end
@@ -23,14 +23,14 @@ module Rivet
23
23
  if ENV['AWS_CONFIG_FILE']
24
24
 
25
25
  current_profile = nil
26
- profile_matcher = /^\[(.*)\]/
26
+ profile_matcher = /^\[(profile+\s)?(\w+)\]/
27
27
  option_matcher = /(\w.*)=(\S.*)\s*/
28
28
  aws_config = Hash.new
29
29
 
30
30
  File.open(ENV['AWS_CONFIG_FILE'],"r").each_line do |line|
31
31
 
32
32
  if line =~ profile_matcher
33
- current_profile = line.match(profile_matcher)[1]
33
+ current_profile = line.match(profile_matcher)[2]
34
34
  aws_config[current_profile] = Hash.new unless aws_config.has_key?(current_profile)
35
35
  end
36
36
 
data/lib/rivet/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Rivet
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rivet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-12 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk