Class: Kitchen::Driver::Aws::StandardPlatform::Freebsd

Inherits:
StandardPlatform
  • Object
show all
Defined in:
lib/kitchen/driver/aws/standard_platform/freebsd.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_image(driver, image) ⇒ Freebsd?

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.

Parameters:

  • driver (Kitchen::Driver::Ec2)

    the driver requesting detection

  • image (Aws::EC2::Image)

    the image to inspect

Returns:

  • (Freebsd, nil)

    a platform when the image is FreeBSD, otherwise nil



90
91
92
93
94
95
# File 'lib/kitchen/driver/aws/standard_platform/freebsd.rb', line 90

def self.from_image(driver, image)
  return unless /freebsd/i.match?(image.name)

  image.name =~ /\b(\d+(\.\d+)?)\b/i
  new(driver, "freebsd", (Regexp.last_match || [])[1], image.architecture)
end

Instance Method Details

#image_searchHash{String => String, Array<String>}

EC2 image filters that select FreeBSD RELEASE images.

A filter is added for Kitchen::Driver::Aws::StandardPlatform#architecture only when one was requested, so that an unspecified architecture matches any of them.

Returns:

  • (Hash{String => String, Array<String>})

    filter name to the value or values it must match

See Also:



51
52
53
54
55
56
57
58
# File 'lib/kitchen/driver/aws/standard_platform/freebsd.rb', line 51

def image_search
  search = {
    "owner-id" => "782442783595",
    "name" => ["FreeBSD #{version}*-RELEASE*", "FreeBSD/EC2 #{version}*-RELEASE*"],
  }
  search["architecture"] = architecture if architecture
  search
end

#sort_by_version(images) ⇒ Array<Aws::EC2::Image>

Sort images newest release first, preferring the cloud-init flavor.

FreeBSD publishes several flavors of each release, distinguished only by a word at the end of the image name, and only the cloud-init flavor is a general-purpose cloud image. "base" and "small" ship without sudo, so a converge fails on them; "builder" is a developer image that does not boot to a usable state on a small instance -- launched on a t3.micro it reaches "impaired" and never opens port 22. Nothing in the name distinguishes them by date or version, so without a preference the flavor selected is effectively arbitrary.

Releases old enough to predate the flavored names publish a single image each. Because this is a stable partition rather than a filter, those are left where the version sort put them.

Parameters:

  • images (Array<Aws::EC2::Image>)

    the images to sort

Returns:

  • (Array<Aws::EC2::Image>)

    the images, best match first



78
79
80
# File 'lib/kitchen/driver/aws/standard_platform/freebsd.rb', line 78

def sort_by_version(images)
  prefer(super) { |image| image.name.include?("cloud-init") }
end

#sudo_commandnil

The command used to elevate privileges on this platform.

FreeBSD AMIs do not configure sudo for the default account, so this is deliberately nil rather than the usual "sudo".

Returns:

  • (nil)

    always



41
# File 'lib/kitchen/driver/aws/standard_platform/freebsd.rb', line 41

def sudo_command; end

#usernameString

The account EC2 creates on this platform's official AMIs.

Used as the SSH username when the transport does not specify one.

Returns:

  • (String)

    the default SSH username



31
32
33
# File 'lib/kitchen/driver/aws/standard_platform/freebsd.rb', line 31

def username
  "ec2-user"
end