Class: Kitchen::Driver::Aws::StandardPlatform::El
- Inherits:
-
StandardPlatform
- Object
- StandardPlatform
- Kitchen::Driver::Aws::StandardPlatform::El
- Defined in:
- lib/kitchen/driver/aws/standard_platform/rhel.rb
Overview
Class Method Summary collapse
-
.from_image(driver, image) ⇒ El?
Detect this platform from an EC2 image.
Instance Method Summary collapse
-
#image_search ⇒ Hash{String => String, Array<String>}
EC2 image filters that select Red Hat Enterprise Linux AMIs published by Red Hat.
-
#initialize(driver, _name, version, architecture) ⇒ El
constructor
Build a Red Hat Enterprise Linux platform.
-
#sort_by_version(images) ⇒ Array<Aws::EC2::Image>
Sort images newest release first, preferring generally available releases over betas.
-
#username ⇒ String
The account EC2 creates on this platform's official AMIs.
Constructor Details
#initialize(driver, _name, version, architecture) ⇒ El
Build a Red Hat Enterprise Linux platform.
This class is registered under both "rhel" and "el", so the name it was constructed with is discarded and normalized to "rhel".
36 37 38 39 |
# File 'lib/kitchen/driver/aws/standard_platform/rhel.rb', line 36 def initialize(driver, _name, version, architecture) # rhel = el super(driver, "rhel", version, architecture) end |
Class Method Details
.from_image(driver, image) ⇒ El?
Detect this platform from an EC2 image.
Matching is done on the image name, which is the only reliable signal EC2 exposes about what an AMI actually contains.
76 77 78 79 80 81 |
# File 'lib/kitchen/driver/aws/standard_platform/rhel.rb', line 76 def self.from_image(driver, image) return unless /rhel/i.match?(image.name) image.name =~ /\b(\d+(\.\d+)?)/i new(driver, "rhel", (Regexp.last_match || [])[1], image.architecture) end |
Instance Method Details
#image_search ⇒ Hash{String => String, Array<String>}
EC2 image filters that select Red Hat Enterprise Linux AMIs published by Red Hat.
A filter is added for Kitchen::Driver::Aws::StandardPlatform#architecture only when one was requested, so that an unspecified architecture matches any of them.
59 60 61 62 63 64 65 66 |
# File 'lib/kitchen/driver/aws/standard_platform/rhel.rb', line 59 def image_search search = { "owner-id" => "309956199498", "name" => "RHEL-#{version}*", } search["architecture"] = architecture if architecture search end |
#sort_by_version(images) ⇒ Array<Aws::EC2::Image>
Sort images newest release first, preferring generally available releases over betas.
A Beta AMI carries a higher version number than the current GA release, so a plain version sort would select it. Betas are pushed to the back after sorting.
92 93 94 95 96 97 98 |
# File 'lib/kitchen/driver/aws/standard_platform/rhel.rb', line 92 def sort_by_version(images) # `prefer(super)`, not `super(images)` followed by # `prefer(images)`: `prefer` returns a new array rather than # reordering in place, so applying it to the original argument # discarded the version sort entirely. prefer(super) { |image| !image.name.match?(/_Beta-/i) } end |
#username ⇒ String
The account EC2 creates on this platform's official AMIs.
RHEL only gained the unprivileged "ec2-user" account in 6.4; earlier releases are logged into as root.
47 48 49 |
# File 'lib/kitchen/driver/aws/standard_platform/rhel.rb', line 47 def username version && version.to_f < 6.4 ? "root" : "ec2-user" end |