Merge pull request #7395 from mitchellh/sethvargo/amazon_guest

Add amazon guest
This commit is contained in:
Seth Vargo 2016-06-06 18:26:22 -04:00
commit 165712c58e
5 changed files with 69 additions and 11 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

@ -6,21 +6,17 @@ module VagrantPlugins
module Redhat
module ChefInstall
def self.chef_install(machine, project, version, channel, options = {})
if dnf?(machine)
machine.communicate.sudo("dnf install -y -q curl")
else
machine.communicate.sudo("yum install -y -q curl")
end
machine.communicate.sudo <<-EOH.gsub(/^ {14}/, '')
if command -v dnf; then
dnf -y install curl
else
yum -y install curl
fi
EOH
command = Omnibus.sh_command(project, version, channel, options)
machine.communicate.sudo(command)
end
protected
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
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