Merge pull request #4492 from tboerger/feature/suse-fixes
SUSE naming and capability fixes
This commit is contained in:
commit
4b4255c6d1
|
@ -4,7 +4,7 @@ module VagrantPlugins
|
|||
class NetworkScriptsDir
|
||||
# The path to the directory with the network configuration scripts.
|
||||
# This is pulled out into its own directory since there are other
|
||||
# operating systems (SuSE) which behave similarly but with a different
|
||||
# operating systems (SUSE) which behave similarly but with a different
|
||||
# path to the network scripts.
|
||||
def self.network_scripts_dir(machine)
|
||||
"/etc/sysconfig/network-scripts"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module VagrantPlugins
|
||||
module GuestSuse
|
||||
module GuestSUSE
|
||||
module Cap
|
||||
class Halt
|
||||
def self.halt(machine)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
require "pathname"
|
||||
|
||||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module HostOpenSUSE
|
||||
class Host < Vagrant.plugin("2", :host)
|
||||
def detect?(env)
|
||||
release_file = Pathname.new("/etc/SuSE-release")
|
||||
|
||||
if release_file.exist?
|
||||
release_file.open("r") do |f|
|
||||
return true if f.gets =~ /^openSUSE/
|
||||
end
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module HostOpenSUSE
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "OpenSUSE host"
|
||||
description "OpenSUSE host support."
|
||||
|
||||
host("opensuse", "linux") do
|
||||
require_relative "host"
|
||||
Host
|
||||
end
|
||||
|
||||
# Linux-specific helpers we need to determine paths that can
|
||||
# be overriden.
|
||||
host_capability("opensuse", "nfs_check_command") do
|
||||
require_relative "cap/nfs"
|
||||
Cap::NFS
|
||||
end
|
||||
|
||||
host_capability("opensuse", "nfs_start_command") do
|
||||
require_relative "cap/nfs"
|
||||
Cap::NFS
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +1,13 @@
|
|||
module VagrantPlugins
|
||||
module HostOpenSUSE
|
||||
module HostSUSE
|
||||
module Cap
|
||||
class NFS
|
||||
def self.nfs_installed(env)
|
||||
system("rpm -q nfs-kernel-server > /dev/null 2>&1")
|
||||
end
|
||||
|
||||
def self.nfs_check_command(env)
|
||||
"/sbin/service nfsserver status"
|
||||
"pidof nfsd > /dev/null"
|
||||
end
|
||||
|
||||
def self.nfs_start_command(env)
|
|
@ -0,0 +1,29 @@
|
|||
require "pathname"
|
||||
|
||||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module HostSUSE
|
||||
class Host < Vagrant.plugin("2", :host)
|
||||
def detect?(env)
|
||||
old_release_file = Pathname.new("/etc/SuSE-release")
|
||||
|
||||
if old_release_file.exist?
|
||||
old_release_file.open("r") do |f|
|
||||
return true if f.gets =~ /^(openSUSE|SUSE Linux Enterprise)/
|
||||
end
|
||||
end
|
||||
|
||||
new_release_file = Pathname.new("/etc/os-release")
|
||||
|
||||
if new_release_file.exist?
|
||||
new_release_file.open("r") do |f|
|
||||
return true if f.gets =~ /(openSUSE|SLES)/
|
||||
end
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module HostSUSE
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "SUSE host"
|
||||
description "SUSE host support."
|
||||
|
||||
host("suse", "linux") do
|
||||
require_relative "host"
|
||||
Host
|
||||
end
|
||||
|
||||
host_capability("suse", "nfs_installed") do
|
||||
require_relative "cap/nfs"
|
||||
Cap::NFS
|
||||
end
|
||||
|
||||
host_capability("suse", "nfs_check_command") do
|
||||
require_relative "cap/nfs"
|
||||
Cap::NFS
|
||||
end
|
||||
|
||||
host_capability("suse", "nfs_start_command") do
|
||||
require_relative "cap/nfs"
|
||||
Cap::NFS
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +1,13 @@
|
|||
module VagrantPlugins
|
||||
module CFEngine
|
||||
module Cap
|
||||
module SuSE
|
||||
module SUSE
|
||||
module CFEngineInstall
|
||||
def self.cfengine_install(machine, config)
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("GPGFILE=$(mktemp) && wget -O $GPGFILE #{config.repo_gpg_key_url} && rpm --import $GPGFILE; rm -f $GPGFILE")
|
||||
comm.sudo("zypper addrepo -t YUM #{config.yum_repo_url} cfengine-repository")
|
||||
comm.sudo("rpm --import #{config.repo_gpg_key_url}")
|
||||
|
||||
comm.sudo("zypper addrepo -t YUM #{config.yum_repo_url} CFEngine")
|
||||
comm.sudo("zypper se #{config.package_name} && zypper -n install #{config.package_name}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module VagrantPlugins
|
|||
|
||||
guest_capability("suse", "cfengine_install") do
|
||||
require_relative "cap/suse/cfengine_install"
|
||||
Cap::SuSE::CFEngineInstall
|
||||
Cap::SUSE::CFEngineInstall
|
||||
end
|
||||
|
||||
provisioner(:cfengine) do
|
||||
|
|
Loading…
Reference in New Issue