From 7b99dfbbab0cc4fee53cb2f6a5d77e5e5b2daa28 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Tue, 10 May 2016 20:36:04 -0700 Subject: [PATCH 01/20] fixes #250 and provides the option to set ssl_peer_verify to false --- README.md | 4 ++++ lib/kitchen/driver/aws/client.rb | 6 ++++-- lib/kitchen/driver/ec2.rb | 4 +++- spec/kitchen/driver/ec2/client_spec.rb | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf13cb79..18b00ef2 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,10 @@ The default is `ENV["HTTPS_PROXY"] || ENV["HTTP_PROXY"]`. If you have these env **Note** - The AWS command line utility allow you to specify [two proxies](http://docs.aws.amazon.com/cli/latest/userguide/cli-http-proxy.html), one for HTTP and one for HTTPS. The AWS Ruby SDK only allows you to specify 1 proxy and because all requests are `https://` this proxy needs to support HTTPS. +### `ssl_verify_peer` + +If you need to turn off ssl certificate verification for HTTP calls made to AWS, set `ssl_verify_peer: false`. + ### Disk Configuration #### `block_device_mappings` diff --git a/lib/kitchen/driver/aws/client.rb b/lib/kitchen/driver/aws/client.rb index 0e85a64c..ad907240 100644 --- a/lib/kitchen/driver/aws/client.rb +++ b/lib/kitchen/driver/aws/client.rb @@ -39,7 +39,8 @@ def initialize( # rubocop:disable Metrics/ParameterLists secret_access_key = nil, session_token = nil, http_proxy = nil, - retry_limit = nil + retry_limit = nil, + ssl_verify_peer = true ) creds = self.class.get_credentials( profile_name, access_key_id, secret_access_key, session_token @@ -47,7 +48,8 @@ def initialize( # rubocop:disable Metrics/ParameterLists ::Aws.config.update( :region => region, :credentials => creds, - :http_proxy => http_proxy + :http_proxy => http_proxy, + :ssl_verify_peer => ssl_verify_peer ) ::Aws.config.update(:retry_limit => retry_limit) unless retry_limit.nil? end diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index d3e89396..09c50d12 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -82,6 +82,7 @@ class Ec2 < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength default_config :http_proxy, ENV["HTTPS_PROXY"] || ENV["HTTP_PROXY"] default_config :retry_limit, 3 default_config :instance_initiated_shutdown_behavior, nil + default_config :ssl_verify_peer, true def initialize(*args, &block) super @@ -313,7 +314,8 @@ def ec2 config[:aws_secret_access_key], config[:aws_session_token], config[:http_proxy], - config[:retry_limit] + config[:retry_limit], + config[:ssl_verify_peer] ) end diff --git a/spec/kitchen/driver/ec2/client_spec.rb b/spec/kitchen/driver/ec2/client_spec.rb index 370cb868..c79d1683 100644 --- a/spec/kitchen/driver/ec2/client_spec.rb +++ b/spec/kitchen/driver/ec2/client_spec.rb @@ -100,7 +100,8 @@ "secret_access_key", "session_token", "http_proxy", - 999 + 999, + false ) } let(:creds) { double("creds") } @@ -111,6 +112,7 @@ expect(Aws.config[:credentials]).to eq(creds) expect(Aws.config[:http_proxy]).to eq("http_proxy") expect(Aws.config[:retry_limit]).to eq(999) + expect(Aws.config[:ssl_verify_peer]).to eq(false) end end end From 61a1c5200eaefdd2e40c9a96948261e4602fa75a Mon Sep 17 00:00:00 2001 From: David Date: Fri, 10 Feb 2017 10:53:55 -0500 Subject: [PATCH 02/20] In the client, only source creds from the shared file when necessary (#259) * Improve credential sourcing logic * Fixes local testing when AWS ENV variables are set --- lib/kitchen/driver/aws/client.rb | 32 ++++++- spec/kitchen/driver/ec2/client_spec.rb | 123 +++++++++++++++++++------ 2 files changed, 121 insertions(+), 34 deletions(-) diff --git a/lib/kitchen/driver/aws/client.rb b/lib/kitchen/driver/aws/client.rb index ad907240..2f646116 100644 --- a/lib/kitchen/driver/aws/client.rb +++ b/lib/kitchen/driver/aws/client.rb @@ -43,7 +43,7 @@ def initialize( # rubocop:disable Metrics/ParameterLists ssl_verify_peer = true ) creds = self.class.get_credentials( - profile_name, access_key_id, secret_access_key, session_token + profile_name, access_key_id, secret_access_key, session_token, region ) ::Aws.config.update( :region => region, @@ -57,8 +57,10 @@ def initialize( # rubocop:disable Metrics/ParameterLists # Try and get the credentials from an ordered list of locations # http://docs.aws.amazon.com/sdkforruby/api/index.html#Configuration # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - def self.get_credentials(profile_name, access_key_id, secret_access_key, session_token) - shared_creds = ::Aws::SharedCredentials.new(:profile_name => profile_name) + # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength + def self.get_credentials(profile_name, access_key_id, secret_access_key, session_token, + region, options = {}) + source_creds = if access_key_id && secret_access_key ::Aws::Credentials.new(access_key_id, secret_access_key, session_token) elsif ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"] @@ -67,14 +69,34 @@ def self.get_credentials(profile_name, access_key_id, secret_access_key, session ENV["AWS_SECRET_ACCESS_KEY"], ENV["AWS_SESSION_TOKEN"] ) - elsif shared_creds.loadable? - shared_creds + elsif profile_name + ::Aws::SharedCredentials.new(:profile_name => profile_name) else ::Aws::InstanceProfileCredentials.new(:retries => 1) end + + if options[:assume_role_arn] && options[:assume_role_session_name] + sts = ::Aws::STS::Client.new(:credentials => source_creds, :region => region) + + assume_role_options = (options[:assume_role_options] || {}).merge( + :client => sts, + :role_arn => options[:assume_role_arn], + :role_session_name => options[:assume_role_session_name] + ) + + ::Aws::AssumeRoleCredentials.new(assume_role_options) + else + source_creds + end end # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + def self.get_shared_creds(profile_name) + ::Aws::SharedCredentials.new(:profile_name => profile_name) + rescue ::Aws::Errors::NoSuchProfileError + false + end + def create_instance(options) resource.create_instances(options)[0] end diff --git a/spec/kitchen/driver/ec2/client_spec.rb b/spec/kitchen/driver/ec2/client_spec.rb index c79d1683..47b9ebee 100644 --- a/spec/kitchen/driver/ec2/client_spec.rb +++ b/spec/kitchen/driver/ec2/client_spec.rb @@ -21,45 +21,48 @@ describe Kitchen::Driver::Aws::Client do describe "::get_credentials" do - let(:shared) { instance_double(Aws::SharedCredentials) } - let(:iam) { instance_double(Aws::InstanceProfileCredentials) } - - before do - expect(Aws::SharedCredentials).to \ - receive(:new).with(:profile_name => "profile").and_return(shared) - end - # nothing else is set, so we default to this it "loads IAM credentials last" do - expect(shared).to receive(:loadable?).and_return(false) - expect(Aws::InstanceProfileCredentials).to receive(:new).and_return(iam) - expect(Kitchen::Driver::Aws::Client.get_credentials("profile", nil, nil, nil)).to eq(iam) + iam = instance_double(Aws::InstanceProfileCredentials) + + allow(Kitchen::Driver::Aws::Client).to receive(:get_shared_creds).and_return(false) + allow(Aws::InstanceProfileCredentials).to receive(:new).and_return(iam) + + env_creds(nil, nil) do + expect(Kitchen::Driver::Aws::Client.get_credentials(nil, nil, nil, nil, nil)).to eq(iam) + end end - it "loads shared credentials second to last" do - expect(shared).to receive(:loadable?).and_return(true) - expect(Kitchen::Driver::Aws::Client.get_credentials("profile", nil, nil, nil)).to eq(shared) + it "loads the shared credentials file second to last" do + shared = instance_double(Aws::SharedCredentials) + + allow(Aws::SharedCredentials).to \ + receive(:new).with(:profile_name => "profile").and_return(shared) + + env_creds(nil, nil) do + expect(Kitchen::Driver::Aws::Client.get_credentials("profile", nil, nil, nil, nil)).to \ + eq(shared) + end end - it "loads shared credentials third to last" do - expect(shared).to_not receive(:loadable?) - ClimateControl.modify( - "AWS_ACCESS_KEY_ID" => "key1", - "AWS_SECRET_ACCESS_KEY" => "value1", - "AWS_SESSION_TOKEN" => "token1" - ) do - expect(Kitchen::Driver::Aws::Client.get_credentials("profile", nil, nil, nil)).to \ + it "loads credentials from the environment third to last" do + env_creds("key_id", "secret") do + expect(Kitchen::Driver::Aws::Client.get_credentials(nil, nil, nil, nil, nil)).to \ be_a(Aws::Credentials).and have_attributes( - :access_key_id => "key1", - :secret_access_key => "value1", - :session_token => "token1" + :access_key_id => "key_id", + :secret_access_key => "secret" ) end end it "loads provided credentials first" do - expect(shared).to_not receive(:loadable?) - expect(Kitchen::Driver::Aws::Client.get_credentials("profile", "key3", "value3", nil)).to \ + expect(Kitchen::Driver::Aws::Client.get_credentials( + "profile", + "key3", + "value3", + nil, + "us-west-1" + )).to \ be_a(Aws::Credentials).and have_attributes( :access_key_id => "key3", :secret_access_key => "value3", @@ -68,8 +71,13 @@ end it "uses a session token if provided" do - expect(shared).to_not receive(:loadable?) - expect(Kitchen::Driver::Aws::Client.get_credentials("profile", "key3", "value3", "t")).to \ + expect(Kitchen::Driver::Aws::Client.get_credentials( + "profile", + "key3", + "value3", + "t", + "us-west-1" + )).to \ be_a(Aws::Credentials).and have_attributes( :access_key_id => "key3", :secret_access_key => "value3", @@ -78,6 +86,55 @@ end end + describe "::get_credentials + STS AssumeRole" do + let(:shared) { instance_double(Aws::SharedCredentials) } + let(:iam) { instance_double(Aws::InstanceProfileCredentials) } + let(:assume_role) { instance_double(Aws::AssumeRoleCredentials) } + let(:sts_client) { instance_double(Aws::STS::Client) } + + before do + expect(Aws::AssumeRoleCredentials).to \ + receive(:new).with( + :client => sts_client, + :role_arn => "role_arn", + :role_session_name => "role_session_name" + ).and_return(assume_role) + end + + # nothing else is set, so we default to this + it "loads an Instance Profile last" do + expect(Aws::InstanceProfileCredentials).to \ + receive(:new).and_return(iam) + expect(Aws::STS::Client).to \ + receive(:new).with(:credentials => iam, :region => "us-west-1").and_return(sts_client) + + expect(Kitchen::Driver::Aws::Client.get_credentials( + nil, + nil, + nil, + nil, + "us-west-1", + :assume_role_arn => "role_arn", :assume_role_session_name => "role_session_name" + )).to eq(assume_role) + end + + it "loads shared credentials second to last" do + expect(::Aws::SharedCredentials).to \ + receive(:new).with(:profile_name => "profile").and_return(shared) + expect(Aws::STS::Client).to \ + receive(:new).with(:credentials => shared, :region => "us-west-1").and_return(sts_client) + + expect(Kitchen::Driver::Aws::Client.get_credentials( + "profile", + nil, + nil, + nil, + "us-west-1", + :assume_role_arn => "role_arn", :assume_role_session_name => "role_session_name" + )).to eq(assume_role) + end + end + let(:client) { Kitchen::Driver::Aws::Client.new("us-west-1") } describe "#initialize" do @@ -125,4 +182,12 @@ expect(client.resource).to be_a(Aws::EC2::Resource) end + def env_creds(key_id, secret, &block) + ClimateControl.modify( + "AWS_ACCESS_KEY_ID" => key_id, + "AWS_SECRET_ACCESS_KEY" => secret + ) do + block.call + end + end end From ffebc45885fbdc84e8f735b58959aae1e76dec5d Mon Sep 17 00:00:00 2001 From: Seth Thomas Date: Fri, 10 Feb 2017 16:03:27 -0500 Subject: [PATCH 03/20] Release 1.3.0 --- CHANGELOG.md | 19 +++++++++++++++++-- lib/kitchen/driver/ec2_version.rb | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc6980d..1e99eeae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,22 @@ # Change Log -## [1.2.0](https://github.com/test-kitchen/kitchen-ec2/tree/1.2.0) (2016-09-12) -[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.1.0...1.2.0) +## [v1.3.0](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.0) (2017-02-10) +[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.2.0...v1.3.0) + +**Implemented Enhancements:** + +- Support Windows 2016 [\#291](https://github.com/test-kitchen/kitchen-ec2/pull/291) ([gdavison](https://github.com/gdavison)) +- Add expiration to spot requests [\#285](https://github.com/test-kitchen/kitchen-ec2/pull/285) ([alanbrent](https://github.com/alanbrent)) +- Don't break if we're using a custom "platform" AMI [\#273](https://github.com/test-kitchen/kitchen-ec2/pull/273) ([hynd](https://github.com/hynd)) +- Propagate tags to volumes [\#260](https://github.com/test-kitchen/kitchen-ec2/pull/260) ([mrbobbytables](https://github.com/mrbobbytables)) +- In the client, only source creds from the shared file when necessary [\#259](https://github.com/test-kitchen/kitchen-ec2/pull/259) ([davidcpell](https://github.com/davidcpell)) +- Add notes for AMI image name requirements [\#252](https://github.com/test-kitchen/kitchen-ec2/pull/252) ([freimer](https://github.com/freimer)) +- Provide the option to set ssl\_peer\_verify to false [\#251](https://github.com/test-kitchen/kitchen-ec2/pull/251) ([mwrock](https://github.com/mwrock)) +- Adding support for tenancy parameter in placement config. [\#235](https://github.com/test-kitchen/kitchen-ec2/pull/235) ([jcastillocano](https://github.com/jcastillocano)) +- Lookup ID from tag [\#232](https://github.com/test-kitchen/kitchen-ec2/pull/232) ([dlukman](https://github.com/dlukman)) + +## [v1.2.0](https://github.com/test-kitchen/kitchen-ec2/tree/v1.2.0) (2016-09-12) +[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.1.0...v1.2.0) **Fixed bugs:** diff --git a/lib/kitchen/driver/ec2_version.rb b/lib/kitchen/driver/ec2_version.rb index ab13c090..6c045a47 100644 --- a/lib/kitchen/driver/ec2_version.rb +++ b/lib/kitchen/driver/ec2_version.rb @@ -21,6 +21,6 @@ module Kitchen module Driver # Version string for EC2 Test Kitchen driver - EC2_VERSION = "1.2.0" + EC2_VERSION = "1.3.0" end end From 5f554ab58e78e0538159bce54bffc033e8269475 Mon Sep 17 00:00:00 2001 From: David Pell Date: Tue, 14 Feb 2017 22:23:40 -0500 Subject: [PATCH 04/20] reinstate default shared creds option This allows a user to rely on a [default] profile getting picked up in the shared credentials file (~/.aws/credentials). Fixes #295 Fixes #258 --- lib/kitchen/driver/aws/client.rb | 6 ++++-- spec/kitchen/driver/ec2/client_spec.rb | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/kitchen/driver/aws/client.rb b/lib/kitchen/driver/aws/client.rb index 2f646116..78c9b099 100644 --- a/lib/kitchen/driver/aws/client.rb +++ b/lib/kitchen/driver/aws/client.rb @@ -71,6 +71,8 @@ def self.get_credentials(profile_name, access_key_id, secret_access_key, session ) elsif profile_name ::Aws::SharedCredentials.new(:profile_name => profile_name) + elsif default_shared_credentials? + ::Aws::SharedCredentials.new else ::Aws::InstanceProfileCredentials.new(:retries => 1) end @@ -91,8 +93,8 @@ def self.get_credentials(profile_name, access_key_id, secret_access_key, session end # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - def self.get_shared_creds(profile_name) - ::Aws::SharedCredentials.new(:profile_name => profile_name) + def self.default_shared_credentials? + ::Aws::SharedCredentials.new.loadable? rescue ::Aws::Errors::NoSuchProfileError false end diff --git a/spec/kitchen/driver/ec2/client_spec.rb b/spec/kitchen/driver/ec2/client_spec.rb index 47b9ebee..3cc11c2d 100644 --- a/spec/kitchen/driver/ec2/client_spec.rb +++ b/spec/kitchen/driver/ec2/client_spec.rb @@ -25,7 +25,7 @@ it "loads IAM credentials last" do iam = instance_double(Aws::InstanceProfileCredentials) - allow(Kitchen::Driver::Aws::Client).to receive(:get_shared_creds).and_return(false) + allow(Kitchen::Driver::Aws::Client).to receive(:default_shared_credentials?).and_return(false) allow(Aws::InstanceProfileCredentials).to receive(:new).and_return(iam) env_creds(nil, nil) do @@ -33,7 +33,20 @@ end end - it "loads the shared credentials file second to last" do + it "loads the default shared creds profile second to last" do + shared = instance_double(Aws::SharedCredentials) + + allow(Kitchen::Driver::Aws::Client).to receive(:default_shared_credentials?).and_return(true) + allow(Aws::SharedCredentials).to \ + receive(:new).and_return(shared) + + env_creds(nil, nil) do + expect(Kitchen::Driver::Aws::Client.get_credentials(nil, nil, nil, nil, nil)).to \ + eq(shared) + end + end + + it "loads a custom shared credentials profile third to last" do shared = instance_double(Aws::SharedCredentials) allow(Aws::SharedCredentials).to \ @@ -103,6 +116,8 @@ # nothing else is set, so we default to this it "loads an Instance Profile last" do + allow(Kitchen::Driver::Aws::Client).to receive(:default_shared_credentials?).and_return(false) + expect(Aws::InstanceProfileCredentials).to \ receive(:new).and_return(iam) expect(Aws::STS::Client).to \ From 56091295f30c982e1a02d4dc4bc750e20f59fbc5 Mon Sep 17 00:00:00 2001 From: Seth Thomas Date: Thu, 16 Feb 2017 11:27:13 -0800 Subject: [PATCH 05/20] Release 1.3.1 hotfix --- CHANGELOG.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e99eeae..79c33443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ # Change Log -## [v1.3.0](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.0) (2017-02-10) +## [v1.3.1](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.1) (2017-02-16) +[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.3.0...v1.3.1) + +**Closed issues:** + +- Shared AWS credentials file being ignored. [\#295](https://github.com/test-kitchen/kitchen-ec2/issues/295) +- Missing AMI generates Nil::NilClass error [\#284](https://github.com/test-kitchen/kitchen-ec2/issues/284) +- `kitchen converge` failing - not prioritizing env vars over ~/.aws/credentials [\#258](https://github.com/test-kitchen/kitchen-ec2/issues/258) + +**Merged pull requests:** + +- reinstate default shared creds option [\#296](https://github.com/test-kitchen/kitchen-ec2/pull/296) ([davidcpell](https://github.com/davidcpell)) + +## [v1.3.0](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.0) (2017-02-11) [Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.2.0...v1.3.0) **Implemented Enhancements:** From 72d1229090a52351685b528076390517df8e71a7 Mon Sep 17 00:00:00 2001 From: Seth Thomas Date: Thu, 16 Feb 2017 11:51:40 -0800 Subject: [PATCH 06/20] Actually bumping version --- lib/kitchen/driver/ec2_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kitchen/driver/ec2_version.rb b/lib/kitchen/driver/ec2_version.rb index 6c045a47..a800ddce 100644 --- a/lib/kitchen/driver/ec2_version.rb +++ b/lib/kitchen/driver/ec2_version.rb @@ -21,6 +21,6 @@ module Kitchen module Driver # Version string for EC2 Test Kitchen driver - EC2_VERSION = "1.3.0" + EC2_VERSION = "1.3.1" end end From 5e0ed0e572b11fdcab290ae552da99d42c99cb6a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 23 Feb 2017 15:21:51 -0800 Subject: [PATCH 07/20] Don't try to set tags if there aren't any. Also fix the map thing because it bugged me. --- lib/kitchen/driver/ec2.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index c86e6eaf..d365a9e6 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -383,22 +383,22 @@ def create_spot_request end def tag_server(server) - if config[:tags] - tags = [] - config[:tags].each do |k, v| - tags << { :key => k, :value => v } + if config[:tags] && !config[:tags].empty? + tags = config[:tags].map do |k, v| + { :key => k, :value => v } end server.create_tags(:tags => tags) end end def tag_volumes(server) - tags = [] - config[:tags].each do |k, v| - tags << { :key => k, :value => v } - end - server.volumes.each do |volume| - volume.create_tags(:tags => tags) + if config[:tags] && !config[:tags].empty? + tags = config[:tags].map do |k, v| + { :key => k, :value => v } + end + server.volumes.each do |volume| + volume.create_tags(:tags => tags) + end end end From fab756bf967a084c59f1c374e1e6e59ff3a5a0ee Mon Sep 17 00:00:00 2001 From: Seth Thomas Date: Fri, 24 Feb 2017 09:50:55 -0500 Subject: [PATCH 08/20] Cut 1.3.2 --- CHANGELOG.md | 7 +++++++ lib/kitchen/driver/ec2_version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c33443..7c3cb9a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [v1.3.2](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.2) (2017-02-24) +[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.3.1...v1.3.2) + +**Improvements:** + +- Don't try to set tags if there aren't any. [\#298](https://github.com/test-kitchen/kitchen-ec2/pull/298) ([coderanger](https://github.com/coderanger)) + ## [v1.3.1](https://github.com/test-kitchen/kitchen-ec2/tree/v1.3.1) (2017-02-16) [Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v1.3.0...v1.3.1) diff --git a/lib/kitchen/driver/ec2_version.rb b/lib/kitchen/driver/ec2_version.rb index a800ddce..63a6c683 100644 --- a/lib/kitchen/driver/ec2_version.rb +++ b/lib/kitchen/driver/ec2_version.rb @@ -21,6 +21,6 @@ module Kitchen module Driver # Version string for EC2 Test Kitchen driver - EC2_VERSION = "1.3.1" + EC2_VERSION = "1.3.2" end end From b5b8cdff7686d1371a588cb6aaf503fc9a6c503e Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:53:09 -0800 Subject: [PATCH 09/20] =?UTF-8?q?Remove=20test-kitchen=20from=20the=20Gemf?= =?UTF-8?q?ile=20as=20it=E2=80=99s=20in=20the=20spec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Smith --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 29ea756d..be3d6e0d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" # Specify your gem"s dependencies in kitchen-ec2.gemspec gemspec -gem "test-kitchen" + gem "winrm-transport" gem "winrm-fs" gem "activesupport", "~> 4.0" From 746dace90c982ffcf21258d6429ba0d82da45434 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:53:16 -0800 Subject: [PATCH 10/20] Test on Ruby 2.4.0 Signed-off-by: Tim Smith --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8d17dc44..b88a59a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,5 @@ sudo: false rvm: - 2.2.6 - 2.3.1 + - 2.4.0 - ruby-head From 9620f88b5729a5e27471822ac21ade9718c527a2 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:55:02 -0800 Subject: [PATCH 11/20] Switch to Chefstyle This matches test-kitchen itself Signed-off-by: Tim Smith --- .rubocop.yml | 21 -- kitchen-ec2.gemspec | 2 +- lib/kitchen/driver/aws/client.rb | 32 +-- lib/kitchen/driver/aws/instance_generator.rb | 20 +- lib/kitchen/driver/aws/standard_platform.rb | 4 +- .../driver/aws/standard_platform/centos.rb | 4 +- .../driver/aws/standard_platform/debian.rb | 4 +- .../driver/aws/standard_platform/fedora.rb | 2 +- .../driver/aws/standard_platform/freebsd.rb | 2 +- .../driver/aws/standard_platform/rhel.rb | 2 +- .../driver/aws/standard_platform/ubuntu.rb | 2 +- .../driver/aws/standard_platform/windows.rb | 6 +- lib/kitchen/driver/ec2.rb | 12 +- spec/kitchen/driver/ec2/client_spec.rb | 6 +- .../driver/ec2/image_selection_spec.rb | 244 +++++++++--------- .../driver/ec2/instance_generator_spec.rb | 86 +++--- spec/kitchen/driver/ec2_spec.rb | 28 +- 17 files changed, 228 insertions(+), 249 deletions(-) delete mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 22562c89..00000000 --- a/.rubocop.yml +++ /dev/null @@ -1,21 +0,0 @@ -Style/FileName: - Exclude: - - 'data/**/*' - -Style/Lambda: - Enabled: false - -Style/Next: - Enabled: false - -Style/DoubleNegation: - Enabled: false - -Metrics/CyclomaticComplexity: - Max: 30 - -Metrics/PerceivedComplexity: - Max: 30 - -Metrics/AbcSize: - Max: 60 diff --git a/kitchen-ec2.gemspec b/kitchen-ec2.gemspec index 89600cef..a75d6f64 100644 --- a/kitchen-ec2.gemspec +++ b/kitchen-ec2.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |gem| # style and complexity libraries are tightly version pinned as newer releases # may introduce new and undesireable style choices which would be immediately # enforced in CI - gem.add_development_dependency "finstyle", "1.4.0" + gem.add_development_dependency "chefstyle", "= 0.5.0" gem.add_development_dependency "climate_control" # github_changelog_generator -> github-api -> oauth2 -> rack diff --git a/lib/kitchen/driver/aws/client.rb b/lib/kitchen/driver/aws/client.rb index 78c9b099..e6461db6 100644 --- a/lib/kitchen/driver/aws/client.rb +++ b/lib/kitchen/driver/aws/client.rb @@ -61,21 +61,21 @@ def initialize( # rubocop:disable Metrics/ParameterLists def self.get_credentials(profile_name, access_key_id, secret_access_key, session_token, region, options = {}) source_creds = - if access_key_id && secret_access_key - ::Aws::Credentials.new(access_key_id, secret_access_key, session_token) - elsif ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"] - ::Aws::Credentials.new( - ENV["AWS_ACCESS_KEY_ID"], - ENV["AWS_SECRET_ACCESS_KEY"], - ENV["AWS_SESSION_TOKEN"] - ) - elsif profile_name - ::Aws::SharedCredentials.new(:profile_name => profile_name) - elsif default_shared_credentials? - ::Aws::SharedCredentials.new - else - ::Aws::InstanceProfileCredentials.new(:retries => 1) - end + if access_key_id && secret_access_key + ::Aws::Credentials.new(access_key_id, secret_access_key, session_token) + elsif ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"] + ::Aws::Credentials.new( + ENV["AWS_ACCESS_KEY_ID"], + ENV["AWS_SECRET_ACCESS_KEY"], + ENV["AWS_SESSION_TOKEN"] + ) + elsif profile_name + ::Aws::SharedCredentials.new(:profile_name => profile_name) + elsif default_shared_credentials? + ::Aws::SharedCredentials.new + else + ::Aws::InstanceProfileCredentials.new(:retries => 1) + end if options[:assume_role_arn] && options[:assume_role_session_name] sts = ::Aws::STS::Client.new(:credentials => source_creds, :region => region) @@ -111,7 +111,7 @@ def get_instance_from_spot_request(request_id) resource.instances( :filters => [{ :name => "spot-instance-request-id", - :values => [request_id] + :values => [request_id], }] ).to_a[0] end diff --git a/lib/kitchen/driver/aws/instance_generator.rb b/lib/kitchen/driver/aws/instance_generator.rb index db15b19f..ceaf1f1d 100644 --- a/lib/kitchen/driver/aws/instance_generator.rb +++ b/lib/kitchen/driver/aws/instance_generator.rb @@ -49,13 +49,13 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize :filters => [ { :name => "tag:#{config[:subnet_filter][:tag]}", - :values => [config[:subnet_filter][:value]] - } + :values => [config[:subnet_filter][:value]], + }, ] )[0][0].subnet_id if config[:subnet_id].nil? - fail "The subnet tagged '#{config[:subnet_filter][:tag]}\ + raise "The subnet tagged '#{config[:subnet_filter][:tag]}\ #{config[:subnet_filter][:value]}' does not exist!" end end @@ -66,13 +66,13 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize :filters => [ { :name => "tag:#{config[:security_group_filter][:tag]}", - :values => [config[:security_group_filter][:value]] - } + :values => [config[:security_group_filter][:value]], + }, ] )[0][0].group_id] if config[:security_group_ids].nil? - fail "The group tagged '#{config[:security_group_filter][:tag]}\ + raise "The group tagged '#{config[:security_group_filter][:tag]}\ #{config[:security_group_filter][:value]}' does not exist!" end end @@ -83,7 +83,7 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize :image_id => config[:image_id], :key_name => config[:aws_ssh_key_id], :subnet_id => config[:subnet_id], - :private_ip_address => config[:private_ip_address] + :private_ip_address => config[:private_ip_address], } availability_zone = config[:availability_zone] @@ -94,7 +94,7 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize i[:placement] = { :availability_zone => availability_zone.downcase } end tenancy = config[:tenancy] - if tenancy && %w[default dedicated].include?(tenancy) + if tenancy && %w{default dedicated}.include?(tenancy) if i.key?(:placement) i[:placement][:tenancy] = tenancy else @@ -114,7 +114,7 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize [{ :device_index => 0, :associate_public_ip_address => config[:associate_public_ip], - :delete_on_termination => true + :delete_on_termination => true, }] # If specifying `:network_interfaces` in the request, you must specify # network specific configs in the network_interfaces block and not at @@ -137,7 +137,7 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize i[:placement] = { :availability_zone => availability_zone.downcase } end tenancy = config[:tenancy] - if tenancy && %w[default dedicated].include?(tenancy) + if tenancy && %w{default dedicated}.include?(tenancy) if i.key?(:placement) i[:placement][:tenancy] = tenancy else diff --git a/lib/kitchen/driver/aws/standard_platform.rb b/lib/kitchen/driver/aws/standard_platform.rb index 55f02af4..b9d0ab0c 100644 --- a/lib/kitchen/driver/aws/standard_platform.rb +++ b/lib/kitchen/driver/aws/standard_platform.rb @@ -138,7 +138,7 @@ def self.from_image(driver, image) # # The list of supported architectures # - ARCHITECTURE = %w[x86_64 i386 i86pc sun4v powerpc] + ARCHITECTURE = %w{x86_64 i386 i86pc sun4v powerpc} protected @@ -162,7 +162,7 @@ def sort_by_version(images) images.group_by do |image| platform = self.class.from_image(driver, image) platform ? platform.version : nil - end.sort_by { |k, _v| k ? k.to_f : nil }.reverse.map { |_k, v| v }.flatten(1) + end.sort_by { |k, _v| k ? k.to_f : nil }.reverse.flat_map { |_k, v| v } end # Not supported yet: aix mac_os_x nexus solaris diff --git a/lib/kitchen/driver/aws/standard_platform/centos.rb b/lib/kitchen/driver/aws/standard_platform/centos.rb index 3665a9ff..8a4504b0 100644 --- a/lib/kitchen/driver/aws/standard_platform/centos.rb +++ b/lib/kitchen/driver/aws/standard_platform/centos.rb @@ -18,7 +18,7 @@ def username def image_search search = { "owner-alias" => "aws-marketplace", - "name" => ["CentOS Linux #{version}*", "CentOS-#{version}*-GA-*"] + "name" => ["CentOS Linux #{version}*", "CentOS-#{version}*-GA-*"], } search["architecture"] = architecture if architecture search @@ -30,7 +30,7 @@ def sort_by_version(images) # ... images.group_by { |image| self.class.from_image(driver, image).version }. sort_by { |k, _v| (k && k.include?(".") ? k.to_f : "#{k}.999".to_f) }. - reverse.map { |_k, v| v }.flatten(1) + reverse.flat_map { |_k, v| v } end def self.from_image(driver, image) diff --git a/lib/kitchen/driver/aws/standard_platform/debian.rb b/lib/kitchen/driver/aws/standard_platform/debian.rb index b3bef8e1..71aa366e 100644 --- a/lib/kitchen/driver/aws/standard_platform/debian.rb +++ b/lib/kitchen/driver/aws/standard_platform/debian.rb @@ -11,7 +11,7 @@ class Debian < StandardPlatform DEBIAN_CODENAMES = { "8" => "jessie", "7" => "wheezy", - "6" => "squeeze" + "6" => "squeeze", } def username @@ -25,7 +25,7 @@ def codename def image_search search = { "owner-id" => "379101102735", - "name" => "debian-#{codename}-*" + "name" => "debian-#{codename}-*", } search["architecture"] = architecture if architecture search diff --git a/lib/kitchen/driver/aws/standard_platform/fedora.rb b/lib/kitchen/driver/aws/standard_platform/fedora.rb index c2319a3d..39bac408 100644 --- a/lib/kitchen/driver/aws/standard_platform/fedora.rb +++ b/lib/kitchen/driver/aws/standard_platform/fedora.rb @@ -15,7 +15,7 @@ def username def image_search search = { "owner-id" => "125523088429", - "name" => version ? "Fedora-Cloud-Base-#{version}-*" : "Fedora-Cloud-Base-*" + "name" => version ? "Fedora-Cloud-Base-#{version}-*" : "Fedora-Cloud-Base-*", } search["architecture"] = architecture if architecture search diff --git a/lib/kitchen/driver/aws/standard_platform/freebsd.rb b/lib/kitchen/driver/aws/standard_platform/freebsd.rb index b45ece9f..23038055 100644 --- a/lib/kitchen/driver/aws/standard_platform/freebsd.rb +++ b/lib/kitchen/driver/aws/standard_platform/freebsd.rb @@ -18,7 +18,7 @@ def sudo_command def image_search search = { "owner-id" => "118940168514", - "name" => ["FreeBSD #{version}*-RELEASE*", "FreeBSD/EC2 #{version}*-RELEASE*"] + "name" => ["FreeBSD #{version}*-RELEASE*", "FreeBSD/EC2 #{version}*-RELEASE*"], } search["architecture"] = architecture if architecture search diff --git a/lib/kitchen/driver/aws/standard_platform/rhel.rb b/lib/kitchen/driver/aws/standard_platform/rhel.rb index 950c3253..b5915ecd 100644 --- a/lib/kitchen/driver/aws/standard_platform/rhel.rb +++ b/lib/kitchen/driver/aws/standard_platform/rhel.rb @@ -21,7 +21,7 @@ def username def image_search search = { "owner-id" => "309956199498", - "name" => "RHEL-#{version}*" + "name" => "RHEL-#{version}*", } search["architecture"] = architecture if architecture search diff --git a/lib/kitchen/driver/aws/standard_platform/ubuntu.rb b/lib/kitchen/driver/aws/standard_platform/ubuntu.rb index 9ed5c614..605a9471 100644 --- a/lib/kitchen/driver/aws/standard_platform/ubuntu.rb +++ b/lib/kitchen/driver/aws/standard_platform/ubuntu.rb @@ -15,7 +15,7 @@ def username def image_search search = { "owner-id" => "099720109477", - "name" => "ubuntu/images/*/ubuntu-*-#{version}*" + "name" => "ubuntu/images/*/ubuntu-*-#{version}*", } search["architecture"] = architecture if architecture search diff --git a/lib/kitchen/driver/aws/standard_platform/windows.rb b/lib/kitchen/driver/aws/standard_platform/windows.rb index 3252bd2d..02933def 100644 --- a/lib/kitchen/driver/aws/standard_platform/windows.rb +++ b/lib/kitchen/driver/aws/standard_platform/windows.rb @@ -35,7 +35,7 @@ def username def image_search search = { "owner-alias" => "amazon", - "name" => windows_name_filter + "name" => windows_name_filter, } search["architecture"] = architecture if architecture search @@ -47,7 +47,7 @@ def sort_by_version(images) # ... images.group_by { |image| self.class.from_image(driver, image).windows_version_parts }. sort_by { |version, _platform_images| version }. - reverse.map { |_version, platform_images| platform_images }.flatten(1) + reverse.flat_map { |_version, platform_images| platform_images } end def self.from_image(driver, image) @@ -101,7 +101,7 @@ def windows_version_parts # Turn service_pack into an integer. rtm = 0, spN = N. if service_pack - service_pack = (service_pack.downcase == "rtm") ? 0 : service_pack[2..-1].to_i + service_pack = (service_pack.casecmp("rtm").zero?) ? 0 : service_pack[2..-1].to_i end end diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index d365a9e6..18618ff6 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -48,15 +48,15 @@ class Ec2 < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength plugin_version Kitchen::Driver::EC2_VERSION - default_config :region, ENV["AWS_REGION"] || "us-east-1" + default_config :region, ENV["AWS_REGION"] || "us-east-1" default_config :shared_credentials_profile, nil - default_config :availability_zone, nil + default_config :availability_zone, nil default_config :instance_type do |driver| driver.default_instance_type end default_config :ebs_optimized, false default_config :security_group_ids, nil - default_config :tags, "created-by" => "test-kitchen" + default_config :tags, "created-by" => "test-kitchen" default_config :user_data do |driver| if driver.windows_os? driver.default_windows_user_data @@ -83,7 +83,7 @@ class Ec2 < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength default_config :retry_limit, 3 default_config :tenancy, "default" default_config :instance_initiated_shutdown_behavior, nil - default_config :ssl_verify_peer, true + default_config :ssl_verify_peer, true def initialize(*args, &block) super @@ -372,7 +372,7 @@ def create_spot_request request_data = { :spot_price => config[:spot_price].to_s, :launch_specification => instance_generator.ec2_instance_data, - :valid_until => Time.now + request_duration + :valid_until => Time.now + request_duration, } if config[:block_duration_minutes] request_data[:block_duration_minutes] = config[:block_duration_minutes] @@ -491,7 +491,7 @@ def fetch_windows_admin_password(server, state) "dns" => "public_dns_name", "public" => "public_ip_address", "private" => "private_ip_address", - "private_dns" => "private_dns_name" + "private_dns" => "private_dns_name", } # diff --git a/spec/kitchen/driver/ec2/client_spec.rb b/spec/kitchen/driver/ec2/client_spec.rb index 3cc11c2d..e6d13a84 100644 --- a/spec/kitchen/driver/ec2/client_spec.rb +++ b/spec/kitchen/driver/ec2/client_spec.rb @@ -164,7 +164,7 @@ end context "when provided all optional parameters" do - let(:client) { + let(:client) do Kitchen::Driver::Aws::Client.new( "us-west-1", "profile_name", @@ -175,7 +175,7 @@ 999, false ) - } + end let(:creds) { double("creds") } it "Sets the AWS config" do expect(Kitchen::Driver::Aws::Client).to receive(:get_credentials).and_return(creds) @@ -202,7 +202,7 @@ def env_creds(key_id, secret, &block) "AWS_ACCESS_KEY_ID" => key_id, "AWS_SECRET_ACCESS_KEY" => secret ) do - block.call + yield end end end diff --git a/spec/kitchen/driver/ec2/image_selection_spec.rb b/spec/kitchen/driver/ec2/image_selection_spec.rb index f4772b03..25cf7ec0 100644 --- a/spec/kitchen/driver/ec2/image_selection_spec.rb +++ b/spec/kitchen/driver/ec2/image_selection_spec.rb @@ -60,246 +60,246 @@ def new_instance(platform_name: "blarghle") PLATFORM_SEARCHES = { "centos" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, - { :name => "name", :values => ["CentOS Linux *", "CentOS-*-GA-*"] } + { :name => "owner-alias", :values => %w{aws-marketplace} }, + { :name => "name", :values => ["CentOS Linux *", "CentOS-*-GA-*"] }, ], "centos-7" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, - { :name => "name", :values => ["CentOS Linux 7*", "CentOS-7*-GA-*"] } + { :name => "owner-alias", :values => %w{aws-marketplace} }, + { :name => "name", :values => ["CentOS Linux 7*", "CentOS-7*-GA-*"] }, ], "centos-6" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, - { :name => "name", :values => ["CentOS Linux 6*", "CentOS-6*-GA-*"] } + { :name => "owner-alias", :values => %w{aws-marketplace} }, + { :name => "name", :values => ["CentOS Linux 6*", "CentOS-6*-GA-*"] }, ], "centos-6.3" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, - { :name => "name", :values => ["CentOS Linux 6.3*", "CentOS-6.3*-GA-*"] } + { :name => "owner-alias", :values => %w{aws-marketplace} }, + { :name => "name", :values => ["CentOS Linux 6.3*", "CentOS-6.3*-GA-*"] }, ], "centos-x86_64" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, + { :name => "owner-alias", :values => %w{aws-marketplace} }, { :name => "name", :values => ["CentOS Linux *", "CentOS-*-GA-*"] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "architecture", :values => %w{x86_64} }, ], "centos-6.3-x86_64" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, + { :name => "owner-alias", :values => %w{aws-marketplace} }, { :name => "name", :values => ["CentOS Linux 6.3*", "CentOS-6.3*-GA-*"] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "architecture", :values => %w{x86_64} }, ], "centos-7-x86_64" => [ - { :name => "owner-alias", :values => %w[aws-marketplace] }, + { :name => "owner-alias", :values => %w{aws-marketplace} }, { :name => "name", :values => ["CentOS Linux 7*", "CentOS-7*-GA-*"] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "architecture", :values => %w{x86_64} }, ], "debian" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-jessie-*] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-jessie-*} }, ], "debian-8" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-jessie-*] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-jessie-*} }, ], "debian-7" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-wheezy-*] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-wheezy-*} }, ], "debian-6" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-squeeze-*] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-squeeze-*} }, ], "debian-x86_64" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-jessie-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-jessie-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "debian-6-x86_64" => [ - { :name => "owner-id", :values => %w[379101102735] }, - { :name => "name", :values => %w[debian-squeeze-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{379101102735} }, + { :name => "name", :values => %w{debian-squeeze-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "rhel" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-*] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-*} }, ], "rhel-6" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-6*] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-6*} }, ], "rhel-7.1" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-7.1*] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-7.1*} }, ], "rhel-x86_64" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "rhel-6-x86_64" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-6*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-6*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "el" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-*] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-*} }, ], "el-6-x86_64" => [ - { :name => "owner-id", :values => %w[309956199498] }, - { :name => "name", :values => %w[RHEL-6*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{309956199498} }, + { :name => "name", :values => %w{RHEL-6*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "fedora" => [ - { :name => "owner-id", :values => %w[125523088429] }, - { :name => "name", :values => %w[Fedora-Cloud-Base-*] } + { :name => "owner-id", :values => %w{125523088429} }, + { :name => "name", :values => %w{Fedora-Cloud-Base-*} }, ], "fedora-22" => [ - { :name => "owner-id", :values => %w[125523088429] }, - { :name => "name", :values => %w[Fedora-Cloud-Base-22-*] } + { :name => "owner-id", :values => %w{125523088429} }, + { :name => "name", :values => %w{Fedora-Cloud-Base-22-*} }, ], "fedora-x86_64" => [ - { :name => "owner-id", :values => %w[125523088429] }, - { :name => "name", :values => %w[Fedora-Cloud-Base-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{125523088429} }, + { :name => "name", :values => %w{Fedora-Cloud-Base-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "fedora-22-x86_64" => [ - { :name => "owner-id", :values => %w[125523088429] }, - { :name => "name", :values => %w[Fedora-Cloud-Base-22-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{125523088429} }, + { :name => "name", :values => %w{Fedora-Cloud-Base-22-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "freebsd" => [ - { :name => "owner-id", :values => %w[118940168514] }, - { :name => "name", :values => ["FreeBSD *-RELEASE*", "FreeBSD/EC2 *-RELEASE*"] } + { :name => "owner-id", :values => %w{118940168514} }, + { :name => "name", :values => ["FreeBSD *-RELEASE*", "FreeBSD/EC2 *-RELEASE*"] }, ], "freebsd-10" => [ - { :name => "owner-id", :values => %w[118940168514] }, - { :name => "name", :values => ["FreeBSD 10*-RELEASE*", "FreeBSD/EC2 10*-RELEASE*"] } + { :name => "owner-id", :values => %w{118940168514} }, + { :name => "name", :values => ["FreeBSD 10*-RELEASE*", "FreeBSD/EC2 10*-RELEASE*"] }, ], "freebsd-10.1" => [ - { :name => "owner-id", :values => %w[118940168514] }, - { :name => "name", :values => ["FreeBSD 10.1*-RELEASE*", "FreeBSD/EC2 10.1*-RELEASE*"] } + { :name => "owner-id", :values => %w{118940168514} }, + { :name => "name", :values => ["FreeBSD 10.1*-RELEASE*", "FreeBSD/EC2 10.1*-RELEASE*"] }, ], "freebsd-x86_64" => [ - { :name => "owner-id", :values => %w[118940168514] }, + { :name => "owner-id", :values => %w{118940168514} }, { :name => "name", :values => ["FreeBSD *-RELEASE*", "FreeBSD/EC2 *-RELEASE*"] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "architecture", :values => %w{x86_64} }, ], "freebsd-10-x86_64" => [ - { :name => "owner-id", :values => %w[118940168514] }, + { :name => "owner-id", :values => %w{118940168514} }, { :name => "name", :values => ["FreeBSD 10*-RELEASE*", "FreeBSD/EC2 10*-RELEASE*"] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "architecture", :values => %w{x86_64} }, ], "ubuntu" => [ - { :name => "owner-id", :values => %w[099720109477] }, - { :name => "name", :values => %w[ubuntu/images/*/ubuntu-*-*] } + { :name => "owner-id", :values => %w{099720109477} }, + { :name => "name", :values => %w{ubuntu/images/*/ubuntu-*-*} }, ], "ubuntu-14" => [ - { :name => "owner-id", :values => %w[099720109477] }, - { :name => "name", :values => %w[ubuntu/images/*/ubuntu-*-14*] } + { :name => "owner-id", :values => %w{099720109477} }, + { :name => "name", :values => %w{ubuntu/images/*/ubuntu-*-14*} }, ], "ubuntu-12.04" => [ - { :name => "owner-id", :values => %w[099720109477] }, - { :name => "name", :values => %w[ubuntu/images/*/ubuntu-*-12.04*] } + { :name => "owner-id", :values => %w{099720109477} }, + { :name => "name", :values => %w{ubuntu/images/*/ubuntu-*-12.04*} }, ], "ubuntu-x86_64" => [ - { :name => "owner-id", :values => %w[099720109477] }, - { :name => "name", :values => %w[ubuntu/images/*/ubuntu-*-*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{099720109477} }, + { :name => "name", :values => %w{ubuntu/images/*/ubuntu-*-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "ubuntu-14-x86_64" => [ - { :name => "owner-id", :values => %w[099720109477] }, - { :name => "name", :values => %w[ubuntu/images/*/ubuntu-*-14*] }, - { :name => "architecture", :values => %w[x86_64] } + { :name => "owner-id", :values => %w{099720109477} }, + { :name => "name", :values => %w{ubuntu/images/*/ubuntu-*-14*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "windows" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* Windows_Server-*-R*_SP*-English-*-Base-* - Windows_Server-*-English-Full-Base-*] } + Windows_Server-*-English-Full-Base-*} }, ], "windows-2008" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-2008-RTM-English-*-Base-* - Windows_Server-2008-SP*-English-*-Base-*] } + Windows_Server-2008-SP*-English-*-Base-*} }, ], "windows-2012" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-2012-RTM-English-*-Base-* - Windows_Server-2012-SP*-English-*-Base-*] } + Windows_Server-2012-SP*-English-*-Base-*} }, ], "windows-2012r2" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-2012-R2_RTM-English-*-Base-* - Windows_Server-2012-R2_SP*-English-*-Base-*] } + Windows_Server-2012-R2_SP*-English-*-Base-*} }, ], "windows-2012sp1" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ - Windows_Server-2012-SP1-English-*-Base-*] } + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ + Windows_Server-2012-SP1-English-*-Base-*} }, ], "windows-2012rtm" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ - Windows_Server-2012-RTM-English-*-Base-*] } + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ + Windows_Server-2012-RTM-English-*-Base-*} }, ], "windows-2012r2sp1" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ - Windows_Server-2012-R2_SP1-English-*-Base-*] } + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ + Windows_Server-2012-R2_SP1-English-*-Base-*} }, ], "windows-2012r2rtm" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ - Windows_Server-2012-R2_RTM-English-*-Base-*] } + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ + Windows_Server-2012-R2_RTM-English-*-Base-*} }, ], "windows-x86_64" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* Windows_Server-*-R*_SP*-English-*-Base-* - Windows_Server-*-English-Full-Base-*] }, - { :name => "architecture", :values => %w[x86_64] } + Windows_Server-*-English-Full-Base-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "windows-2012r2-x86_64" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-2012-R2_RTM-English-*-Base-* - Windows_Server-2012-R2_SP*-English-*-Base-*] }, - { :name => "architecture", :values => %w[x86_64] } + Windows_Server-2012-R2_SP*-English-*-Base-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "windows-server" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* Windows_Server-*-R*_SP*-English-*-Base-* - Windows_Server-*-English-Full-Base-*] } + Windows_Server-*-English-Full-Base-*} }, ], "windows-server-2012r2-x86_64" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ Windows_Server-2012-R2_RTM-English-*-Base-* - Windows_Server-2012-R2_SP*-English-*-Base-*] }, - { :name => "architecture", :values => %w[x86_64] } + Windows_Server-2012-R2_SP*-English-*-Base-*} }, + { :name => "architecture", :values => %w{x86_64} }, ], "windows-2016" => [ - { :name => "owner-alias", :values => %w[amazon] }, - { :name => "name", :values => %w[ - Windows_Server-2016-English-Full-Base-*] } - ] + { :name => "owner-alias", :values => %w{amazon} }, + { :name => "name", :values => %w{ + Windows_Server-2016-English-Full-Base-*} }, + ], } describe "Platform defaults" do @@ -329,7 +329,7 @@ def new_instance(platform_name: "blarghle") it "searches for an image id without using the standard filters" do expect(driver.ec2.resource). to receive(:images). - with(:filters => [{ :name => "name", :values => %w[SuperImage] }]). + with(:filters => [{ :name => "name", :values => %w{SuperImage} }]). and_return([image]) expect(driver.ec2.resource). to receive(:image).with(image.id).and_return(image) @@ -345,7 +345,7 @@ def new_instance(platform_name: "blarghle") it "does not search for (or find) an image, and informs the user they need to set image_id" do expect(driver.ec2.resource). to receive(:images). - with(:filters => [{ :name => "name", :values => %w[SuperImage] }]). + with(:filters => [{ :name => "name", :values => %w{SuperImage} }]). and_return([image]) expect(driver.ec2.resource). to receive(:image).with(image.id).and_return(image) diff --git a/spec/kitchen/driver/ec2/instance_generator_spec.rb b/spec/kitchen/driver/ec2/instance_generator_spec.rb index cceb73be..e881c811 100644 --- a/spec/kitchen/driver/ec2/instance_generator_spec.rb +++ b/spec/kitchen/driver/ec2/instance_generator_spec.rb @@ -27,7 +27,7 @@ let(:config) { Hash.new } let(:resource) { instance_double(Aws::EC2::Resource) } let(:ec2) { instance_double(Kitchen::Driver::Aws::Client, :resource => resource) } - let(:logger) { instance_double(Logger) } + let(:logger) { instance_double(Logger) } let(:generator) { Kitchen::Driver::Aws::InstanceGenerator.new(config, ec2, logger) } describe "#prepared_user_data" do @@ -67,8 +67,8 @@ :subnets => [ { :subnet_id => "s-123", - :tags => [{ :key => "foo", :value => "bar" }] - } + :tags => [{ :key => "foo", :value => "bar" }], + }, ] ) @@ -77,8 +77,8 @@ :security_groups => [ { :group_id => "sg-123", - :tags => [{ :key => "foo", :value => "bar" }] - } + :tags => [{ :key => "foo", :value => "bar" }], + }, ] ) @@ -100,7 +100,7 @@ :ebs_optimized => true, :image_id => "ami-123", :subnet_id => "s-456", - :private_ip_address => "0.0.0.0" + :private_ip_address => "0.0.0.0", } end @@ -124,7 +124,7 @@ :image_id => "ami-123", :aws_ssh_key_id => "key", :subnet_id => "s-456", - :private_ip_address => "0.0.0.0" + :private_ip_address => "0.0.0.0", } end @@ -152,8 +152,8 @@ :subnet_filter => { :tag => "foo", - :value => "bar" - } + :value => "bar", + }, } end @@ -163,8 +163,8 @@ :filters => [ { :name => "tag:foo", - :values => ["bar"] - } + :values => ["bar"], + }, ] ).and_return(ec2_stub.describe_subnets) expect(generator.ec2_instance_data[:subnet_id]).to eq("s-123") @@ -184,8 +184,8 @@ :security_group_filter => { :tag => "foo", - :value => "bar" - } + :value => "bar", + }, } end @@ -195,8 +195,8 @@ :filters => [ { :name => "tag:foo", - :values => ["bar"] - } + :values => ["bar"], + }, ] ).and_return(ec2_stub.describe_security_groups) expect(generator.ec2_instance_data[:security_group_ids]).to eq(["sg-123"]) @@ -212,7 +212,7 @@ :aws_ssh_key_id => "key", :subnet_id => "s-456", :private_ip_address => "0.0.0.0", - :block_device_mappings => [] + :block_device_mappings => [], } end @@ -232,7 +232,7 @@ let(:config) do { :region => "eu-east-1", - :availability_zone => "eu-west-1c" + :availability_zone => "eu-west-1c", } end it "returns that in the instance data" do @@ -252,7 +252,7 @@ let(:config) do { :region => "eu-east-1", - :availability_zone => "c" + :availability_zone => "c", } end it "adds the region to it in the instance data" do @@ -271,7 +271,7 @@ context "when availability_zone is not provided" do let(:config) do { - :region => "eu-east-1" + :region => "eu-east-1", } end it "is not added to the instance data" do @@ -291,7 +291,7 @@ { :region => "eu-east-1", :availability_zone => "c", - :tenancy => "dedicated" + :tenancy => "dedicated", } end it "adds the region to it in the instance data" do @@ -312,7 +312,7 @@ let(:config) do { :region => "eu-east-1", - :tenancy => "default" + :tenancy => "default", } end it "is not added to the instance data" do @@ -332,7 +332,7 @@ let(:config) do { :region => "eu-east-1", - :tenancy => "ephemeral" + :tenancy => "ephemeral", } end it "is not added to the instance data" do @@ -352,7 +352,7 @@ { :region => "eu-east-1", :availability_zone => "c", - :tenancy => "dedicated" + :tenancy => "dedicated", } end it "adds the region to it in the instance data" do @@ -373,7 +373,7 @@ let(:config) do { :region => "eu-east-1", - :tenancy => "default" + :tenancy => "default", } end it "is not added to the instance data" do @@ -393,7 +393,7 @@ let(:config) do { :region => "eu-east-1", - :tenancy => "ephemeral" + :tenancy => "ephemeral", } end it "is not added to the instance data" do @@ -411,7 +411,7 @@ context "when subnet_id is provided" do let(:config) do { - :subnet_id => "s-456" + :subnet_id => "s-456", } end @@ -430,7 +430,7 @@ context "when associate_public_ip is provided" do let(:config) do { - :associate_public_ip => true + :associate_public_ip => true, } end @@ -445,7 +445,7 @@ :network_interfaces => [{ :device_index => 0, :associate_public_ip_address => true, - :delete_on_termination => true + :delete_on_termination => true, }] ) end @@ -454,7 +454,7 @@ let(:config) do { :associate_public_ip => true, - :subnet_id => "s-456" + :subnet_id => "s-456", } end @@ -469,7 +469,7 @@ :device_index => 0, :associate_public_ip_address => true, :delete_on_termination => true, - :subnet_id => "s-456" + :subnet_id => "s-456", }] ) end @@ -479,7 +479,7 @@ let(:config) do { :associate_public_ip => true, - :security_group_ids => ["sg-789"] + :security_group_ids => ["sg-789"], } end @@ -495,7 +495,7 @@ :device_index => 0, :associate_public_ip_address => true, :delete_on_termination => true, - :groups => ["sg-789"] + :groups => ["sg-789"], }] ) end @@ -508,7 +508,7 @@ :device_index => 0, :associate_public_ip_address => true, :delete_on_termination => true, - :groups => ["only-one"] + :groups => ["only-one"], }] ) end @@ -518,7 +518,7 @@ let(:config) do { :associate_public_ip => true, - :private_ip_address => "0.0.0.0" + :private_ip_address => "0.0.0.0", } end @@ -533,7 +533,7 @@ :device_index => 0, :associate_public_ip_address => true, :delete_on_termination => true, - :private_ip_address => "0.0.0.0" + :private_ip_address => "0.0.0.0", }] ) end @@ -558,14 +558,14 @@ :volume_size => 15, :delete_on_termination => false, :volume_type => "gp2", - :snapshot_id => "id" - } - } + :snapshot_id => "id", + }, + }, ], :security_group_ids => ["sg-789"], :user_data => "foo", :iam_profile_name => "iam-123", - :associate_public_ip => true + :associate_public_ip => true, } end @@ -583,9 +583,9 @@ :volume_size => 15, :delete_on_termination => false, :volume_type => "gp2", - :snapshot_id => "id" - } - } + :snapshot_id => "id", + }, + }, ], :iam_instance_profile => { :name => "iam-123" }, :network_interfaces => [{ @@ -594,7 +594,7 @@ :subnet_id => "s-456", :delete_on_termination => true, :groups => ["sg-789"], - :private_ip_address => "0.0.0.0" + :private_ip_address => "0.0.0.0", }], :placement => { :availability_zone => "eu-west-1a" }, :user_data => Base64.encode64("foo") diff --git a/spec/kitchen/driver/ec2_spec.rb b/spec/kitchen/driver/ec2_spec.rb index 1a8edcf4..579cb0f1 100644 --- a/spec/kitchen/driver/ec2_spec.rb +++ b/spec/kitchen/driver/ec2_spec.rb @@ -29,7 +29,7 @@ { :aws_ssh_key_id => "key", :image_id => "ami-1234567", - :block_duration_minutes => 60 + :block_duration_minutes => 60, } end let(:platform) { Kitchen::Platform.new(:name => "fooos-99") } @@ -79,18 +79,18 @@ allow(instance).to receive(:name).and_return("instance_name") end context "Windows 2016" do - let(:image) { + let(:image) do FakeImage.new(:name => "Windows_Server-2016-English-Full-Base-2017.01.11") - } + end it "sets :user_data to something" do expect(driver[:user_data]).to include '$logfile=C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Log\\kitchen-ec2.log' end end context "Windows 2012R2" do - let(:image) { + let(:image) do FakeImage.new(:name => "Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.01.11") - } + end it "sets :user_data to something" do expect(driver[:user_data]).to include '$logfile=C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log' @@ -104,14 +104,14 @@ let(:private_dns_name) { nil } let(:public_ip_address) { nil } let(:private_ip_address) { nil } - let(:server) { + let(:server) do double("server", :public_dns_name => public_dns_name, :private_dns_name => private_dns_name, :public_ip_address => public_ip_address, :private_ip_address => private_ip_address ) - } + end it "returns nil if all sources are nil" do expect(driver.hostname(server)).to eq(nil) @@ -235,9 +235,9 @@ describe "#submit_spot" do let(:state) { {} } - let(:response) { + let(:response) do { :spot_instance_requests => [{ :spot_instance_request_id => "id" }] } - } + end before do expect(driver).to receive(:instance).at_least(:once).and_return(instance) @@ -265,7 +265,7 @@ expect(server).to receive(:create_tags).with( :tags => [ { :key => :key1, :value => :value1 }, - { :key => :key2, :value => :value2 } + { :key => :key2, :value => :value2 }, ] ) driver.tag_server(server) @@ -286,7 +286,7 @@ expect(volume).to receive(:create_tags).with( :tags => [ { :key => :key1, :value => :value1 }, - { :key => :key2, :value => :value2 } + { :key => :key2, :value => :value2 }, ] ) driver.tag_volumes(server) @@ -407,7 +407,7 @@ let(:tries) { 111 } let(:sleep) { 222 } let(:msg) { "msg" } - given_block = lambda do; end + given_block = lambda { ; } before do config[:retryable_sleep] = sleep @@ -429,9 +429,9 @@ expect(server).to receive(:wait_until).and_raise(::Aws::Waiters::Errors::WaiterFailed) expect(driver).to receive(:destroy).with(state) expect(driver).to receive(:error).with(/#{msg}/) - expect { + expect do driver.wait_with_destroy(server, state, msg, &given_block) - }.to raise_error(::Aws::Waiters::Errors::WaiterFailed) + end.to raise_error(::Aws::Waiters::Errors::WaiterFailed) end end From 4e165ff8c67b212683ace94663fb3c8c7ab43a6c Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:55:26 -0800 Subject: [PATCH 12/20] Remove Rake constraint Signed-off-by: Tim Smith --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index be3d6e0d..cf3e7ff6 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem "activesupport", "~> 4.0" gem "faraday-http-cache", "~> 1.3" group :test do - gem "rake", "< 12" + gem "rake" gem "pry" end From fb7e2dec87b4029a4b6e6680bee07c8d66291ee1 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:55:47 -0800 Subject: [PATCH 13/20] Move github_changelog_generator back to the gem spec Signed-off-by: Tim Smith --- Gemfile | 4 ---- kitchen-ec2.gemspec | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index cf3e7ff6..2bf72d36 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,3 @@ group :test do gem "rake" gem "pry" end - -group :development do - gem "github_changelog_generator" -end diff --git a/kitchen-ec2.gemspec b/kitchen-ec2.gemspec index a75d6f64..1ce32070 100644 --- a/kitchen-ec2.gemspec +++ b/kitchen-ec2.gemspec @@ -30,8 +30,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency "simplecov", "~> 0.7" gem.add_development_dependency "yard", "~> 0.8" - # conflicts with finstyle 1.4.0 - # gem.add_development_dependency "github_changelog_generator" + gem.add_development_dependency "github_changelog_generator" # style and complexity libraries are tightly version pinned as newer releases # may introduce new and undesireable style choices which would be immediately From 64df820405c455fbe824f76ffdb349ab88bcd309 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:56:15 -0800 Subject: [PATCH 14/20] Remove rack constraint. Removes Ruby 2.1 support Signed-off-by: Tim Smith --- kitchen-ec2.gemspec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kitchen-ec2.gemspec b/kitchen-ec2.gemspec index 1ce32070..1afc5ddf 100644 --- a/kitchen-ec2.gemspec +++ b/kitchen-ec2.gemspec @@ -37,8 +37,4 @@ Gem::Specification.new do |gem| # enforced in CI gem.add_development_dependency "chefstyle", "= 0.5.0" gem.add_development_dependency "climate_control" - - # github_changelog_generator -> github-api -> oauth2 -> rack - # rack being unconstrained breaks Ruby 2.1 installs - gem.add_development_dependency "rack", "~> 1.0" end From bc1f065a626c6b4fa7133598f7c8f89a2ecf7291 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 12:59:05 -0800 Subject: [PATCH 15/20] Use chefstyle in Rake Signed-off-by: Tim Smith --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index eb9aef2e..7b710980 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ task :stats do sh "countloc -r spec features" end -require "finstyle" +require "chefstyle" require "rubocop/rake_task" RuboCop::RakeTask.new(:style) do |task| task.options << "--display-cop-names" From 84b2da2229ec33b49670c6e297b69a3c9a0c62fc Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 13:01:15 -0800 Subject: [PATCH 16/20] Require Ruby 2.2.2. Also only test on master in Travis to avoid double testing Signed-off-by: Tim Smith --- .travis.yml | 5 ++++- kitchen-ec2.gemspec | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b88a59a5..938b311b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,11 @@ language: ruby cache: bundler sudo: false +branches: + only: + - master rvm: - 2.2.6 - - 2.3.1 + - 2.3.3 - 2.4.0 - ruby-head diff --git a/kitchen-ec2.gemspec b/kitchen-ec2.gemspec index 1afc5ddf..443979a8 100644 --- a/kitchen-ec2.gemspec +++ b/kitchen-ec2.gemspec @@ -18,6 +18,8 @@ Gem::Specification.new do |gem| gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + gem.required_ruby_version = ">= 2.2.2" + gem.add_dependency "test-kitchen", "~> 1.4", ">= 1.4.1" gem.add_dependency "excon" gem.add_dependency "multi_json" From 1e142c9bab941047ce2bedbdd86bbd572197a11c Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 26 Feb 2017 13:26:18 -0800 Subject: [PATCH 17/20] Fix 1 last chefstyle warning Signed-off-by: Tim Smith --- lib/kitchen/driver/aws/standard_platform/windows.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kitchen/driver/aws/standard_platform/windows.rb b/lib/kitchen/driver/aws/standard_platform/windows.rb index 02933def..73064b25 100644 --- a/lib/kitchen/driver/aws/standard_platform/windows.rb +++ b/lib/kitchen/driver/aws/standard_platform/windows.rb @@ -101,7 +101,7 @@ def windows_version_parts # Turn service_pack into an integer. rtm = 0, spN = N. if service_pack - service_pack = (service_pack.casecmp("rtm").zero?) ? 0 : service_pack[2..-1].to_i + service_pack = (service_pack.casecmp("rtm") == 0) ? 0 : service_pack[2..-1].to_i end end From d801b179131c8957a9d45b60984acf6c8f42deb7 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Feb 2017 15:56:31 -0800 Subject: [PATCH 18/20] Correct the docs for image_id Not sure if this used to work, but definitely needs the driver section now. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 002e2219..d9fface5 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ working with! ```yaml platforms: - name: centos-7 - image_id: ami-96a818fe + driver: + image_id: ami-96a818fe ``` image_id's have a format like ami-748e2903. The image_id values appear next to the image names when you select 'Launch Instance' from the AWS EC2 console. You can also see the list from the AWS CLI ````aws ec2 describe-images````. From 1d28ef30886baca09f7da324b4a5b66b75b64113 Mon Sep 17 00:00:00 2001 From: Phil Porada Date: Sun, 26 Feb 2017 19:46:34 -0500 Subject: [PATCH 19/20] Updated readme based on issue 300 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9fface5..6168021e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Once that is done, create your kitchen file in your cookbook directory (or an empty directory if you just want to get a feel for it): -1. `kitchen init -D ec2` +1. `kitchen init -D kitchen-ec2` 2. Edit `.kitchen.yml` and add the aws_ssh_key_id to driver and a transport with an ssh_key: From e0ff2bc392807ffb63894a3cb6377244f699ae5a Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Wed, 1 Mar 2017 07:30:48 -0800 Subject: [PATCH 20/20] modernize winrm setup and fix for 2008r2 Signed-off-by: Matt Wrock --- lib/kitchen/driver/ec2.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index d365a9e6..7bf293f5 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -567,13 +567,15 @@ def default_windows_user_data # Allow script execution Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force #PS Remoting and & winrm.cmd basic config - Enable-PSRemoting -Force -SkipNetworkProfileCheck + $enableArgs=@{Force=$true} + $command=Get-Command Enable-PSRemoting + if($command.Parameters.Keys -contains "skipnetworkprofilecheck"){ + $enableArgs.skipnetworkprofilecheck=$true + } + Enable-PSRemoting @enableArgs & winrm.cmd set winrm/config '@{MaxTimeoutms="1800000"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxShellsPerUser="50"}' >> $logfile - #Server settings - support username/password login - & winrm.cmd set winrm/config/service/auth '@{Basic="true"}' >> $logfile - & winrm.cmd set winrm/config/service '@{AllowUnencrypted="true"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile #Firewall Config & netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any >> $logfile