Fixed and extended suse guest capabilities

In order to get a SUSE guest running and installing fine i have added a
correct capability for installing rsync and nfs-client.

I have included SUSE naming fixes as well because SUSe doesnt get
spelled SuSE anymore :).
This commit is contained in:
Thomas Boerger 2014-09-11 10:52:58 +02:00
parent 6c20b6cd34
commit 063a903bdb
8 changed files with 64 additions and 15 deletions

View File

@ -1,13 +1,14 @@
module VagrantPlugins
module GuestSuse
module GuestSUSE
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
machine.communicate.tap do |comm|
# Only do this if the hostname is not already set
if !comm.test("sudo hostname | grep '#{name}'")
unless comm.test("sudo hostname | grep '#{name}'")
comm.sudo("echo #{name} > /etc/HOSTNAME")
comm.sudo("hostname #{name}")
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
end
end

View File

@ -5,7 +5,7 @@ require "vagrant/util/retryable"
require "vagrant/util/template_renderer"
module VagrantPlugins
module GuestSuse
module GuestSUSE
module Cap
class ConfigureNetworks
extend Vagrant::Util::Retryable

View File

@ -1,5 +1,5 @@
module VagrantPlugins
module GuestSuse
module GuestSUSE
module Cap
class Halt
def self.halt(machine)

View File

@ -1,9 +1,9 @@
module VagrantPlugins
module GuestSuse
module GuestSUSE
module Cap
class NetworkScriptsDir
def self.network_scripts_dir(machine)
"/etc/sysconfig/network/"
"/etc/sysconfig/network"
end
end
end

View File

@ -0,0 +1,16 @@
module VagrantPlugins
module GuestSUSE
module Cap
class NFSClient
def self.nfs_client_install(machine)
machine.communicate.tap do |comm|
comm.sudo("zypper -n install nfs-client")
comm.sudo("/sbin/service rpcbind restart")
comm.sudo("/sbin/service nfs restart")
end
end
end
end
end
end

View File

@ -0,0 +1,17 @@
module VagrantPlugins
module GuestSUSE
module Cap
class RSync
def self.rsync_installed(machine)
machine.communicate.test("test -f /usr/bin/rsync")
end
def self.rsync_install(machine)
machine.communicate.tap do |comm|
comm.sudo("zypper -n install rsync")
end
end
end
end
end
end

View File

@ -1,10 +1,10 @@
require "vagrant"
module VagrantPlugins
module GuestSuse
module GuestSUSE
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
machine.communicate.test("cat /etc/SuSE-release")
machine.communicate.test("test -f /etc/SuSE-release || grep -q SUSE /etc/os-release")
end
end
end

View File

@ -1,12 +1,12 @@
require "vagrant"
module VagrantPlugins
module GuestSuse
module GuestSUSE
class Plugin < Vagrant.plugin("2")
name "SUSE guest"
description "SUSE guest support."
guest("suse", "redhat") do
guest("suse", "linux") do
require File.expand_path("../guest", __FILE__)
Guest
end
@ -16,20 +16,35 @@ module VagrantPlugins
Cap::ChangeHostName
end
guest_capability("suse", "halt") do
require_relative "cap/halt"
Cap::Halt
end
guest_capability("suse", "configure_networks") do
require_relative "cap/configure_networks"
Cap::ConfigureNetworks
end
guest_capability("suse", "halt") do
require_relative "cap/halt"
Cap::Halt
end
guest_capability("suse", "network_scripts_dir") do
require_relative "cap/network_scripts_dir"
Cap::NetworkScriptsDir
end
guest_capability("suse", "nfs_client_install") do
require_relative "cap/nfs_client"
Cap::NFSClient
end
guest_capability("suse", "rsync_install") do
require_relative "cap/rsync"
Cap::RSync
end
guest_capability("suse", "rsync_installed") do
require_relative "cap/rsync"
Cap::RSync
end
end
end
end