Add Rocky Linux guest support

This commit is contained in:
Chris Roberts 2021-07-02 15:32:48 -07:00
parent 24a00ee3b3
commit a8c5980afb
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,23 @@
module VagrantPlugins
module GuestRocky
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
:rocky
else
"rocky_#{version}".to_sym
end
end
end
end
end
end

View File

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

View File

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

View File

@ -0,0 +1,36 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestRocky::Cap::Flavor" do
let(:caps) do
VagrantPlugins::GuestRocky::Plugin
.components
.guest_capabilities[:rocky]
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) }
{
"" => :rocky,
"8.2" => :rocky_8,
"9" => :rocky_9,
"invalid" => :rocky
}.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