From 7941939816b66dc8c618c38364f168f4f57822a6 Mon Sep 17 00:00:00 2001 From: Ben Dean Date: Thu, 2 Feb 2023 18:54:15 -0500 Subject: [PATCH] fix: Switch CentOS 7 to new AWS account owner, add CentOS stream to search adding the `"CentOS Stream #{version}*"` pattern will also allow `centos-9` for the platform. remove CentOS 6 since it's not published anymore, even on the legacy marketplace product code. Fixes #589 Signed-off-by: Ben Dean --- .../driver/aws/standard_platform/centos.rb | 25 +-------------- .../driver/aws/image_selection_spec.rb | 32 ++++--------------- 2 files changed, 8 insertions(+), 49 deletions(-) diff --git a/lib/kitchen/driver/aws/standard_platform/centos.rb b/lib/kitchen/driver/aws/standard_platform/centos.rb index 0476e841..41875adf 100644 --- a/lib/kitchen/driver/aws/standard_platform/centos.rb +++ b/lib/kitchen/driver/aws/standard_platform/centos.rb @@ -24,20 +24,10 @@ class Centos < StandardPlatform StandardPlatform.platforms["centos"] = self CENTOS_OWNER_ID = "125523088429".freeze - PRODUCT_CODES = { - "6" => "6x5jmcajty9edm3f211pqjfn2", - "7" => "aw0evgkw8e5c1q413zgy5pjce", - # It appears that v8 is not published to the - # AWS marketplace and hence does not have a product code - }.freeze # default username for this platform's ami # @return [String] def username - # Centos 6.x images use root as the username (but the "centos 6" - # updateable image uses "centos") - return "root" if version && version.start_with?("6.") - "centos" end @@ -45,22 +35,9 @@ def image_search # Version 8+ are published directly, not to the AWS marketplace. Use OWNER ID. search = { "owner-id" => CENTOS_OWNER_ID, - "name" => ["CentOS #{version}*", "CentOS-#{version}*-GA-*"], + "name" => ["CentOS #{version}*", "CentOS-#{version}*-GA-*", "CentOS Linux #{version}*", "CentOS Stream #{version}*"], } - if version && version.split(".").first.to_i < 8 - # Versions <8 are published to the AWS marketplace and use a different naming convention - search = { - "owner-alias" => "aws-marketplace", - "name" => ["CentOS Linux #{version}*", "CentOS-#{version}*-GA-*"], - } - # For versions published to aws-marketplace, additionally filter on product code to - # avoid non-official AMIs. Can't use CentOS owner ID here, as the owner ID is that of aws marketplace. - # https://github.com/test-kitchen/kitchen-ec2/issues/456 - PRODUCT_CODES.keys.each do |major_version| - search["product-code"] = PRODUCT_CODES[major_version] if version.start_with?(major_version) - end - end search["architecture"] = architecture if architecture search end diff --git a/spec/kitchen/driver/aws/image_selection_spec.rb b/spec/kitchen/driver/aws/image_selection_spec.rb index 992ace19..1eb0ad92 100644 --- a/spec/kitchen/driver/aws/image_selection_spec.rb +++ b/spec/kitchen/driver/aws/image_selection_spec.rb @@ -81,42 +81,24 @@ def new_instance(platform_name: "blarghle") "centos" => [ { name: "owner-id", values: %w{125523088429} }, - { name: "name", values: ["CentOS *", "CentOS-*-GA-*"] }, + { name: "name", values: ["CentOS *", "CentOS-*-GA-*", "CentOS Linux *", "CentOS Stream *"] }, ], "centos-8" => [ { name: "owner-id", values: %w{125523088429} }, - { name: "name", values: ["CentOS 8*", "CentOS-8*-GA-*"] }, + { name: "name", values: ["CentOS 8*", "CentOS-8*-GA-*", "CentOS Linux 8*", "CentOS Stream 8*"] }, ], "centos-7" => [ - { name: "owner-alias", values: %w{aws-marketplace} }, - { name: "name", values: ["CentOS Linux 7*", "CentOS-7*-GA-*"] }, - { name: "product-code", values: ["aw0evgkw8e5c1q413zgy5pjce"] }, - ], - "centos-6" => [ - { name: "owner-alias", values: %w{aws-marketplace} }, - { name: "name", values: ["CentOS Linux 6*", "CentOS-6*-GA-*"] }, - { name: "product-code", values: ["6x5jmcajty9edm3f211pqjfn2"] }, - ], - "centos-6.3" => [ - { name: "owner-alias", values: %w{aws-marketplace} }, - { name: "name", values: ["CentOS Linux 6.3*", "CentOS-6.3*-GA-*"] }, - { name: "product-code", values: ["6x5jmcajty9edm3f211pqjfn2"] }, + { name: "owner-id", values: %w{125523088429} }, + { name: "name", values: ["CentOS 7*", "CentOS-7*-GA-*", "CentOS Linux 7*", "CentOS Stream 7*"] }, ], "centos-x86_64" => [ { name: "owner-id", values: %w{125523088429} }, - { name: "name", values: ["CentOS *", "CentOS-*-GA-*"] }, - { name: "architecture", values: %w{x86_64} }, - ], - "centos-6.3-x86_64" => [ - { name: "owner-alias", values: %w{aws-marketplace} }, - { name: "name", values: ["CentOS Linux 6.3*", "CentOS-6.3*-GA-*"] }, - { name: "product-code", values: ["6x5jmcajty9edm3f211pqjfn2"] }, + { name: "name", values: ["CentOS *", "CentOS-*-GA-*", "CentOS Linux *", "CentOS Stream *"] }, { name: "architecture", values: %w{x86_64} }, ], "centos-7-x86_64" => [ - { name: "owner-alias", values: %w{aws-marketplace} }, - { name: "name", values: ["CentOS Linux 7*", "CentOS-7*-GA-*"] }, - { name: "product-code", values: ["aw0evgkw8e5c1q413zgy5pjce"] }, + { name: "owner-id", values: %w{125523088429} }, + { name: "name", values: ["CentOS 7*", "CentOS-7*-GA-*", "CentOS Linux 7*", "CentOS Stream 7*"] }, { name: "architecture", values: %w{x86_64} }, ],