guests: add Alma Linux guest support

This commit is contained in:
Dusty Mabe 2022-06-03 23:48:01 -04:00 committed by sophia
parent d82d0fb657
commit 3ad20c4c7b
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,23 @@
module VagrantPlugins
module GuestAlma
module Cap
class Flavor
def self.flavor(machine)
# Read the version file
version = ""
machine.communicate.sudo("source /etc/os-release && printf $VERSION_ID") do |type, data|
if type == :stdout
version = data.split(".").first.to_i
end
end
if version.nil? || version < 1
:alma
else
"alma_#{version}".to_sym
end
end
end
end
end
end

View File

@ -0,0 +1,10 @@
require_relative "../linux/guest"
module VagrantPlugins
module GuestAlma
class Guest < VagrantPlugins::GuestLinux::Guest
# Name used for guest detection
GUEST_DETECTION_NAME = "almalinux".freeze
end
end
end

View File

@ -0,0 +1,20 @@
require "vagrant"
module VagrantPlugins
module GuestAlma
class Plugin < Vagrant.plugin("2")
name "Alma guest"
description "Alma guest support."
guest(:alma, :redhat) do
require_relative "guest"
Guest
end
guest_capability(:alma, :flavor) do
require_relative "cap/flavor"
Cap::Flavor
end
end
end
end

View File

@ -0,0 +1,36 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestAlma::Cap::Flavor" do
let(:caps) do
VagrantPlugins::GuestAlma::Plugin
.components
.guest_capabilities[:alma]
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".flavor" do
let(:cap) { caps.get(:flavor) }
{
"" => :alma,
"8.2" => :alma_8,
"9" => :alma_9,
"invalid" => :alma
}.each do |str, expected|
it "returns #{expected} for #{str}" do
comm.stub_command("source /etc/os-release && printf $VERSION_ID", stdout: str)
expect(cap.flavor(machine)).to be(expected)
end
end
end
end