diff --git a/.travis.yml b/.travis.yml index 781d0c8e..8d17dc44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,6 @@ language: ruby cache: bundler sudo: false rvm: - - 2.0.0 - - 2.1 - - 2.2 + - 2.2.6 + - 2.3.1 + - ruby-head diff --git a/Gemfile b/Gemfile index 1fdf469f..29ea756d 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem "activesupport", "~> 4.0" gem "faraday-http-cache", "~> 1.3" group :test do - gem "rake" + gem "rake", "< 12" gem "pry" end diff --git a/lib/kitchen/driver/aws/standard_platform/windows.rb b/lib/kitchen/driver/aws/standard_platform/windows.rb index ac0ab76a..3252bd2d 100644 --- a/lib/kitchen/driver/aws/standard_platform/windows.rb +++ b/lib/kitchen/driver/aws/standard_platform/windows.rb @@ -16,7 +16,8 @@ def username # # "windows" -> [nil, nil, nil] # Windows_Server-*-R*_RTM-, Windows_Server-*-R*_SP*-, - # Windows_Server-*-RTM-, Windows_Server-*-SP*- + # Windows_Server-*-RTM-, Windows_Server-*-SP*-, + # Windows_Server-*- # "windows-2012" -> [2012, 0, nil] # Windows_Server-2012-RTM-, Windows_Server-2012-SP*- # "windows-2012r2" -> [2012, 2, nil] @@ -29,6 +30,8 @@ def username # Windows_Server-2012-R2_SP1- # "windows-2012r2rtm" -> [2012, 2, 0] # Windows_Server-2012-R2_RTM- + # "windows-2016" -> [2016, 0, nil] + # Windows_Server-2016- def image_search search = { "owner-alias" => "amazon", @@ -75,6 +78,7 @@ def self.from_image(driver, image) # 2012r2sp4 -> [ 2012, 2, 4 ] # 2012sp4 -> [ 2012, 0, 4 ] # 2012rtm -> [ 2012, 0, 0 ] + # 2016 -> [ 2016, 0, nil ] def windows_version_parts version = self.version if version @@ -106,29 +110,35 @@ def windows_version_parts private - def windows_name_filter + def windows_name_filter # rubocop:disable Metrics/MethodLength major, revision, service_pack = windows_version_parts - case revision - when nil - revision_strings = ["", "R*_"] - when 0 - revision_strings = [""] + if major == 2016 + "Windows_Server-2016-English-Full-Base-*" else - revision_strings = ["R#{revision}_"] - end + case revision + when nil + revision_strings = ["", "R*_"] + when 0 + revision_strings = [""] + else + revision_strings = ["R#{revision}_"] + end - case service_pack - when nil - revision_strings = revision_strings.flat_map { |r| ["#{r}RTM", "#{r}SP*"] } - when 0 - revision_strings = revision_strings.map { |r| "#{r}RTM" } - else - revision_strings = revision_strings.map { |r| "#{r}SP#{service_pack}" } - end + case service_pack + when nil + revision_strings = revision_strings.flat_map { |r| ["#{r}RTM", "#{r}SP*"] } + when 0 + revision_strings = revision_strings.map { |r| "#{r}RTM" } + else + revision_strings = revision_strings.map { |r| "#{r}SP#{service_pack}" } + end - revision_strings.map do |r| - "Windows_Server-#{major || "*"}-#{r}-English-*-Base-*" + name_filter = revision_strings.map do |r| + "Windows_Server-#{major || "*"}-#{r}-English-*-Base-*" + end + name_filter << "Windows_Server-*-English-Full-Base-*" if major.nil? + name_filter end end end diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index 18401b70..bcfef8dd 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -553,10 +553,15 @@ def default_windows_user_data EOH end + if actual_platform.version =~ /2016/ + logfile_name = 'C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Log\\kitchen-ec2.log' + else + logfile_name = 'C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log' + end # Returning the fully constructed PowerShell script to user_data Kitchen::Util.outdent!(<<-EOH) - $logfile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log" + $logfile=#{logfile_name} # Allow script execution Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force #PS Remoting and & winrm.cmd basic config diff --git a/spec/kitchen/driver/ec2/image_selection_spec.rb b/spec/kitchen/driver/ec2/image_selection_spec.rb index 111decea..f4772b03 100644 --- a/spec/kitchen/driver/ec2/image_selection_spec.rb +++ b/spec/kitchen/driver/ec2/image_selection_spec.rb @@ -221,7 +221,8 @@ def new_instance(platform_name: "blarghle") Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* - Windows_Server-*-R*_SP*-English-*-Base-*] } + Windows_Server-*-R*_SP*-English-*-Base-* + Windows_Server-*-English-Full-Base-*] } ], "windows-2008" => [ { :name => "owner-alias", :values => %w[amazon] }, @@ -267,7 +268,8 @@ def new_instance(platform_name: "blarghle") Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* - Windows_Server-*-R*_SP*-English-*-Base-*] }, + Windows_Server-*-R*_SP*-English-*-Base-* + Windows_Server-*-English-Full-Base-*] }, { :name => "architecture", :values => %w[x86_64] } ], "windows-2012r2-x86_64" => [ @@ -283,7 +285,8 @@ def new_instance(platform_name: "blarghle") Windows_Server-*-RTM-English-*-Base-* Windows_Server-*-SP*-English-*-Base-* Windows_Server-*-R*_RTM-English-*-Base-* - Windows_Server-*-R*_SP*-English-*-Base-*] } + Windows_Server-*-R*_SP*-English-*-Base-* + Windows_Server-*-English-Full-Base-*] } ], "windows-server-2012r2-x86_64" => [ { :name => "owner-alias", :values => %w[amazon] }, @@ -291,6 +294,11 @@ def new_instance(platform_name: "blarghle") Windows_Server-2012-R2_RTM-English-*-Base-* 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-*] } ] } diff --git a/spec/kitchen/driver/ec2_spec.rb b/spec/kitchen/driver/ec2_spec.rb index af871d90..1a8edcf4 100644 --- a/spec/kitchen/driver/ec2_spec.rb +++ b/spec/kitchen/driver/ec2_spec.rb @@ -70,6 +70,35 @@ Kitchen::Driver::EC2_VERSION) end + describe "default_config" do + context "Windows" do + let(:resource) { instance_double(::Aws::EC2::Resource, :image => image) } + before do + allow(driver).to receive(:windows_os?).and_return(true) + allow(client).to receive(:resource).and_return(resource) + allow(instance).to receive(:name).and_return("instance_name") + end + context "Windows 2016" do + let(:image) { + FakeImage.new(:name => "Windows_Server-2016-English-Full-Base-2017.01.11") + } + 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) { + FakeImage.new(:name => "Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.01.11") + } + it "sets :user_data to something" do + expect(driver[:user_data]).to include + '$logfile=C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log' + end + end + end + end + describe "#hostname" do let(:public_dns_name) { nil } let(:private_dns_name) { nil }