kitchen-ec2 0.4.0 → 0.5.0

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.
data/.cane ADDED
File without changes
data/.tailor ADDED
@@ -0,0 +1,106 @@
1
+ #------------------------------------------------------------------------------
2
+ # Horizontal Whitespace
3
+ #------------------------------------------------------------------------------
4
+ # allow_hard_tabs True to let hard tabs be considered a single space.
5
+ # Default: false
6
+ #
7
+ # allow_trailing_line_spaces
8
+ # True to skip detecting extra spaces at the ends of
9
+ # lines.
10
+ # Default: false
11
+ #
12
+ # indentation_spaces The number of spaces to consider a proper indent.
13
+ # Default: 2
14
+ #
15
+ # max_line_length The maximum number of characters in a line before
16
+ # tailor complains.
17
+ # Default: 80
18
+ # spaces_after_comma Number of spaces to expect after a comma.
19
+ # Default: 1
20
+ #
21
+ # spaces_before_comma Number of spaces to expect before a comma.
22
+ # Default: 0
23
+ #
24
+ # spaces_after_lbrace The number of spaces to expect after an lbrace ('{').
25
+ # Default: 1
26
+ #
27
+ # spaces_before_lbrace The number of spaces to expect before an lbrace ('{').
28
+ # Default: 1
29
+ #
30
+ # spaces_before_rbrace The number of spaces to expect before an rbrace ('}').
31
+ # Default: 1
32
+ #
33
+ # spaces_in_empty_braces The number of spaces to expect between braces when
34
+ # there's nothing in the braces (i.e. {}).
35
+ # Default: 0
36
+ #
37
+ # spaces_after_lbracket The number of spaces to expect after an
38
+ # lbracket ('[').
39
+ # Default: 0
40
+ #
41
+ # spaces_before_rbracket The number of spaces to expect before an
42
+ # rbracket (']').
43
+ # Default: 0
44
+ #
45
+ # spaces_after_lparen The number of spaces to expect after an
46
+ # lparen ('(').
47
+ # Default: 0
48
+ #
49
+ # spaces_before_rparen The number of spaces to expect before an
50
+ # rbracket (')').
51
+ # Default: 0
52
+ #
53
+ #------------------------------------------------------------------------------
54
+ # Naming
55
+ #------------------------------------------------------------------------------
56
+ # allow_camel_case_methods
57
+ # Setting to true skips detection of camel-case method
58
+ # names (i.e. def myMethod).
59
+ # Default: false
60
+ #
61
+ # allow_screaming_snake_case_classes
62
+ # Setting to true skips detection of screaming
63
+ # snake-case class names (i.e. My_Class).
64
+ # Default: false
65
+ #
66
+ #------------------------------------------------------------------------------
67
+ # Vertical Whitespace
68
+ #------------------------------------------------------------------------------
69
+ # max_code_lines_in_class The number of lines of code in a class to allow before
70
+ # tailor will warn you.
71
+ # Default: 300
72
+ #
73
+ # max_code_lines_in_method
74
+ # The number of lines of code in a method to allow
75
+ # before tailor will warn you.
76
+ # Default: 30
77
+ #
78
+ # trailing_newlines The number of newlines that should be at the end of
79
+ # the file.
80
+ # Default: 1
81
+ #
82
+ Tailor.config do |config|
83
+ config.formatters "text"
84
+ config.file_set 'lib/**/*.rb' do |style|
85
+ style.allow_camel_case_methods false, level: :error
86
+ style.allow_hard_tabs false, level: :error
87
+ style.allow_screaming_snake_case_classes false, level: :error
88
+ style.allow_trailing_line_spaces false, level: :error
89
+ style.allow_invalid_ruby false, level: :warn
90
+ style.indentation_spaces 2, level: :error
91
+ style.max_code_lines_in_class 300, level: :error
92
+ style.max_code_lines_in_method 30, level: :error
93
+ style.max_line_length 80, level: :error
94
+ style.spaces_after_comma 1, level: :off
95
+ style.spaces_after_lbrace 1, level: :error
96
+ style.spaces_after_lbracket 0, level: :error
97
+ style.spaces_after_lparen 0, level: :error
98
+ style.spaces_before_comma 0, level: :error
99
+ style.spaces_before_lbrace 1, level: :off
100
+ style.spaces_before_rbrace 1, level: :error
101
+ style.spaces_before_rbracket 0, level: :error
102
+ style.spaces_before_rparen 0, level: :error
103
+ style.spaces_in_empty_braces 0, level: :error
104
+ style.trailing_newlines 1, level: :error
105
+ end
106
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ ## 0.5.0 / 2013-05-23
2
+
3
+ ### New features
4
+
5
+ * Pull request [#5][]: Add the ability to give ec2 instances tags. ([@halcyonCorsair][])
6
+ * Add required_config attributes for driver. ([@fnichol][])
7
+
8
+ ### Improvements
9
+
10
+ * Write README. ([@fnichol][])
11
+ * Pull request [#2][]: Extra EC2 server creation debugging. ([@mattray][])
12
+ * Remove default_config :port in favor of SSHBase default (also 22). ([@fnichol][])
13
+
14
+ <!--- The following link definition list is generated by PimpMyChangelog --->
15
+ [#2]: https://github.com/opscode/kitchen-ec2/issues/2
16
+ [#5]: https://github.com/opscode/kitchen-ec2/issues/5
17
+ [@fnichol]: https://github.com/fnichol
18
+ [@halcyonCorsair]: https://github.com/halcyonCorsair
19
+ [@mattray]: https://github.com/mattray
data/README.md CHANGED
@@ -1,29 +1,217 @@
1
- # Kitchen::Driver::Ec2
1
+ # <a name="title"></a> Kitchen::Ec2: A Test Kitchen Driver for Amazon EC2
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-ec2.png)](http://badge.fury.io/rb/kitchen-ec2)
4
+ [![Build Status](https://travis-ci.org/opscode/kitchen-ec2.png)](https://travis-ci.org/opscode/kitchen-ec2)
5
+ [![Code Climate](https://codeclimate.com/github/opscode/kitchen-ec2.png)](https://codeclimate.com/github/opscode/kitchen-ec2)
4
6
 
5
- ## Installation
7
+ A Test Kitchen Driver for Amazon EC2.
6
8
 
7
- Add this line to your application's Gemfile:
9
+ This driver uses the [fog gem][fog_gem] to provision and destroy EC2
10
+ instances. Use Amazon's cloud for your infrastructure testing!
8
11
 
9
- gem 'kitchen-ec2'
12
+ ## <a name="requirements"></a> Requirements
10
13
 
11
- And then execute:
14
+ There are **no** external system requirements for this driver. However you
15
+ will need access to an [AWS][aws_site] account.
12
16
 
13
- $ bundle
17
+ ## <a name="installation"></a> Installation and Setup
14
18
 
15
- Or install it yourself as:
19
+ Please read the [Driver usage][driver_usage] page for more details.
16
20
 
17
- $ gem install kitchen-ec2
21
+ ## <a name="config"></a> Configuration
18
22
 
19
- ## Usage
23
+ ### <a name="config-az"></a> availability\_zone
20
24
 
21
- TODO: Write usage instructions here
25
+ **Required** The AWS [availability zone][region_docs] to use.
22
26
 
23
- ## Contributing
27
+ The default is `"us-east-1b"`.
24
28
 
25
- 1. Fork it
29
+ ### <a name="config-aws-access-key-id"></a> aws\_access\_key\_id
30
+
31
+ **Required** The AWS [access key id][credentials_docs] to use.
32
+
33
+ The default is unset, or `nil`.
34
+
35
+ ### <a name="config-aws-secret-access-key"></a> aws\_secret\_access\_key
36
+
37
+ **Required** The AWS [secret access key][credentials_docs] to use.
38
+
39
+ The default is unset, or `nil`.
40
+
41
+ ### <a name="config-aws-ssh-key-id"></a> aws\_ssh\_key\_id
42
+
43
+ **Required** The EC2 [SSH key id][key_id_docs] to use.
44
+
45
+ The default is unset, or `nil`.
46
+
47
+ ### <a name="config-flavor-id"></a> flavor\_id
48
+
49
+ The EC2 [instance type][instance_docs] (also known as size) to use.
50
+
51
+ The default is `"m1.small"`.
52
+
53
+ ### <a name="config-groups"></a> groups
54
+
55
+ An Array of EC [security groups][group_docs] which will be applied to the
56
+ instance.
57
+
58
+ The default is `["default"]`.
59
+
60
+ ### <a name="config-image-id"></a> image\_id
61
+
62
+ **Required** The EC2 [AMI id][ami_docs] to use.
63
+
64
+ The default is unset, or `nil`.
65
+
66
+ ### <a name="config-port"></a> port
67
+
68
+ The SSH port number to be used when communicating with the instance.
69
+
70
+ The default is `22`.
71
+
72
+ ### <a name="config-region"></a> region
73
+
74
+ **Required** The AWS [region][region_docs] to use.
75
+
76
+ The default is `"us-east-1"`.
77
+
78
+ ### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
79
+
80
+ Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
81
+ installed. There are several different behaviors available:
82
+
83
+ * `true` - the latest release will be installed. Subsequent converges
84
+ will skip re-installing if chef is present.
85
+ * `latest` - the latest release will be installed. Subsequent converges
86
+ will always re-install even if chef is present.
87
+ * `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
88
+ be passed the the install.sh script. Subsequent converges will skip if
89
+ the installed version and the desired version match.
90
+ * `false` or `nil` - no chef is installed.
91
+
92
+ The default value is unset, or `nil`.
93
+
94
+ ### <a name="config-ssh-key"></a> ssh\_key
95
+
96
+ Path to the private SSH key used to connect to the instance.
97
+
98
+ The default is unset, or `nil`.
99
+
100
+ ### <a name="config-sudo"></a> sudo
101
+
102
+ Whether or not to prefix remote system commands such as installing and
103
+ running Chef with `sudo`.
104
+
105
+ The default is `true`.
106
+
107
+ ### <a name="config-tags"></a> tags
108
+
109
+ The Hash of EC tag name/value pairs which will be applied to the instance.
110
+
111
+ The default is `{ "created-by" => "test-kitchen" }`.
112
+
113
+ ### <a name="config-username"></a> username
114
+
115
+ The SSH username that will be used to communicate with the instance.
116
+
117
+ The default is `"root"`.
118
+
119
+ ## <a name="example"></a> Example
120
+
121
+ The following could be used in a `.kitchen.yml` or in a `.kitchen.local.yml`
122
+ to override default configuration.
123
+
124
+ ```yaml
125
+ ---
126
+ driver_plugin: ec2
127
+ driver_config:
128
+ aws_access_key_id: KAS...
129
+ aws_secret_access_key: 3UK...
130
+ aws_ssh_key_id: id_rsa-aws
131
+ ssh_key: /path/to/id_rsa-aws
132
+ region: us-east-1
133
+ availability_zone: us-east-1b
134
+ require_chef_omnibus: true
135
+
136
+ platforms:
137
+ - name: ubuntu-12.04
138
+ driver_config:
139
+ image_id: ami-fd20ad94
140
+ username: ubuntu
141
+ - name: centos-6.3
142
+ driver_config:
143
+ image_id: ami-ef5ff086
144
+ username: ec2-user
145
+
146
+ suites:
147
+ # ...
148
+ ```
149
+
150
+ Both `.kitchen.yml` and `.kitchen.local.yml` files are pre-processed through
151
+ ERB which can help to factor out secrets and credentials. For example:
152
+
153
+ ```yaml
154
+ ---
155
+ driver_plugin: ec2
156
+ driver_config:
157
+ aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
158
+ aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
159
+ aws_ssh_key_id: <%= ENV['AWS_SSH_KEY_ID'] %>
160
+ ssh_key: <%= File.expand_path('~/.ssh/id_rsa') %>
161
+ region: us-east-1
162
+ availability_zone: us-east-1b
163
+ require_chef_omnibus: true
164
+
165
+ platforms:
166
+ - name: ubuntu-12.04
167
+ driver_config:
168
+ image_id: ami-fd20ad94
169
+ username: ubuntu
170
+ - name: centos-6.3
171
+ driver_config:
172
+ image_id: ami-ef5ff086
173
+ username: ec2-user
174
+
175
+ suites:
176
+ # ...
177
+ ```
178
+
179
+ ## <a name="development"></a> Development
180
+
181
+ * Source hosted at [GitHub][repo]
182
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
183
+
184
+ Pull requests are very welcome! Make sure your patches are well tested.
185
+ Ideally create a topic branch for every separate change you make. For
186
+ example:
187
+
188
+ 1. Fork the repo
26
189
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
190
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
191
  4. Push to the branch (`git push origin my-new-feature`)
29
192
  5. Create new Pull Request
193
+
194
+ ## <a name="authors"></a> Authors
195
+
196
+ Created and maintained by [Fletcher Nichol][author] (<fnichol@nichol.ca>)
197
+
198
+ ## <a name="license"></a> License
199
+
200
+ Apache 2.0 (see [LICENSE][license])
201
+
202
+
203
+ [author]: https://github.com/fnichol
204
+ [issues]: https://github.com/opscode/kitchen-ec2/issues
205
+ [license]: https://github.com/opscode/kitchen-ec2/blob/master/LICENSE
206
+ [repo]: https://github.com/opscode/kitchen-ec2
207
+ [driver_usage]: http://docs.kitchen-ci.org/drivers/usage
208
+ [chef_omnibus_dl]: http://www.opscode.com/chef/install/
209
+
210
+ [ami_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html
211
+ [aws_site]: http://aws.amazon.com/
212
+ [credentials_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html#using-credentials-access-key
213
+ [fog_gem]: http://fog.io/
214
+ [group_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
215
+ [instance_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
216
+ [key_id_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/verifying-your-key-pair.html
217
+ [region_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
data/Rakefile CHANGED
@@ -3,7 +3,9 @@ require 'cane/rake_task'
3
3
  require 'tailor/rake_task'
4
4
 
5
5
  desc "Run cane to check quality metrics"
6
- Cane::RakeTask.new
6
+ Cane::RakeTask.new do |cane|
7
+ cane.canefile = './.cane'
8
+ end
7
9
 
8
10
  Tailor::RakeTask.new
9
11
 
@@ -13,4 +15,7 @@ task :stats do
13
15
  sh "countloc -r lib/kitchen"
14
16
  end
15
17
 
16
- task :default => [ :cane, :tailor, :stats ]
18
+ desc "Run all quality tasks"
19
+ task :quality => [:cane, :tailor, :stats]
20
+
21
+ task :default => [:quality]
data/kitchen-ec2.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency 'test-kitchen', '~> 1.0.0.alpha.0'
20
+ gem.add_dependency 'test-kitchen', '~> 1.0.0.alpha.7'
21
21
  gem.add_dependency 'fog'
22
22
 
23
23
  gem.add_development_dependency 'cane'
@@ -33,9 +33,14 @@ module Kitchen
33
33
  default_config :region, 'us-east-1'
34
34
  default_config :availability_zone, 'us-east-1b'
35
35
  default_config :flavor_id, 'm1.small'
36
- default_config :groups, [ 'default' ]
36
+ default_config :groups, ['default']
37
+ default_config :tags, { 'created-by' => 'test-kitchen' }
37
38
  default_config :username, 'root'
38
- default_config :port, '22'
39
+
40
+ required_config :aws_access_key_id
41
+ required_config :aws_secret_access_key
42
+ required_config :aws_ssh_key_id
43
+ required_config :image_id
39
44
 
40
45
  def create(state)
41
46
  server = create_server
@@ -45,6 +50,7 @@ module Kitchen
45
50
  server.wait_for { print "."; ready? } ; print "(server ready)"
46
51
  state[:hostname] = server.public_ip_address
47
52
  wait_for_sshd(state[:hostname]) ; print "(ssh ready)\n"
53
+ debug("ec2:create '#{state[:hostname]}'")
48
54
  rescue Fog::Errors::Error, Excon::Errors::Error => ex
49
55
  raise ActionFailed, ex.message
50
56
  end
@@ -71,14 +77,27 @@ module Kitchen
71
77
  end
72
78
 
73
79
  def create_server
80
+ debug_server_config
81
+
74
82
  connection.servers.create(
75
83
  :availability_zone => config[:availability_zone],
76
84
  :groups => config[:groups],
85
+ :tags => config[:tags],
77
86
  :flavor_id => config[:flavor_id],
78
87
  :image_id => config[:image_id],
79
88
  :key_name => config[:aws_ssh_key_id],
80
89
  )
81
90
  end
91
+
92
+ def debug_server_config
93
+ debug("ec2:region '#{config[:region]}'")
94
+ debug("ec2:availability_zone '#{config[:availability_zone]}'")
95
+ debug("ec2:flavor_id '#{config[:flavor_id]}'")
96
+ debug("ec2:image_id '#{config[:image_id]}'")
97
+ debug("ec2:groups '#{config[:groups]}'")
98
+ debug("ec2:tags '#{config[:tags]}'")
99
+ debug("ec2:key_name '#{config[:aws_ssh_key_id]}'")
100
+ end
82
101
  end
83
102
  end
84
103
  end
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for EC2 Test Kitchen driver
24
- EC2_VERSION = "0.4.0"
24
+ EC2_VERSION = "0.5.0"
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.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-03-02 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-kitchen
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0.alpha.0
21
+ version: 1.0.0.alpha.7
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.0.alpha.0
29
+ version: 1.0.0.alpha.7
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: fog
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -98,8 +98,11 @@ executables: []
98
98
  extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
+ - .cane
101
102
  - .gitignore
103
+ - .tailor
102
104
  - .travis.yml
105
+ - CHANGELOG.md
103
106
  - Gemfile
104
107
  - LICENSE
105
108
  - README.md
@@ -121,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
124
  version: '0'
122
125
  segments:
123
126
  - 0
124
- hash: 4246554264751038241
127
+ hash: -927622726583194128
125
128
  required_rubygems_version: !ruby/object:Gem::Requirement
126
129
  none: false
127
130
  requirements:
@@ -130,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  version: '0'
131
134
  segments:
132
135
  - 0
133
- hash: 4246554264751038241
136
+ hash: -927622726583194128
134
137
  requirements: []
135
138
  rubyforge_project:
136
139
  rubygems_version: 1.8.24