guests/amazon: Initial addition

Fixes GH-7254
This commit is contained in:
Seth Vargo 2016-06-06 18:22:34 -04:00
parent e925f3793a
commit c8ceb06f6d
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,14 @@
module VagrantPlugins
module GuestAmazon
module Cap
class Flavor
def self.flavor(machine)
# Amazon AMI is a frankenstien RHEL, mainly based on 6
# Maybe in the future if they incoporate RHEL 7 elements
# this should be extended to read /etc/os-release or similar
return :rhel
end
end
end
end
end

View File

@ -0,0 +1,9 @@
module VagrantPlugins
module GuestAmazon
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
machine.communicate.test("grep 'Amazon Linux AMI' /etc/os-release")
end
end
end
end

View File

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

View File

@ -0,0 +1,19 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestAmazon::Cap::Flavor" do
let(:caps) do
VagrantPlugins::GuestAmazon::Plugin
.components
.guest_capabilities[:amazon]
end
let(:machine) { double("machine") }
describe ".flavor" do
let(:cap) { caps.get(:flavor) }
it "returns rhel" do
expect(cap.flavor(machine)).to be(:rhel)
end
end
end