diff --git a/plugins/guests/fedora/cap/network_scripts_dir.rb b/plugins/guests/fedora/cap/network_scripts_dir.rb index 3ce0e43c3..82a4abad7 100644 --- a/plugins/guests/fedora/cap/network_scripts_dir.rb +++ b/plugins/guests/fedora/cap/network_scripts_dir.rb @@ -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" diff --git a/plugins/guests/suse/cap/change_host_name.rb b/plugins/guests/suse/cap/change_host_name.rb index a8ba242d7..e4b9cee56 100644 --- a/plugins/guests/suse/cap/change_host_name.rb +++ b/plugins/guests/suse/cap/change_host_name.rb @@ -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 diff --git a/plugins/guests/suse/cap/configure_networks.rb b/plugins/guests/suse/cap/configure_networks.rb index d60bb8306..00902dbd0 100644 --- a/plugins/guests/suse/cap/configure_networks.rb +++ b/plugins/guests/suse/cap/configure_networks.rb @@ -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 diff --git a/plugins/guests/suse/cap/halt.rb b/plugins/guests/suse/cap/halt.rb index ea1957594..e6b20818b 100644 --- a/plugins/guests/suse/cap/halt.rb +++ b/plugins/guests/suse/cap/halt.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module GuestSuse + module GuestSUSE module Cap class Halt def self.halt(machine) diff --git a/plugins/guests/suse/cap/network_scripts_dir.rb b/plugins/guests/suse/cap/network_scripts_dir.rb index d8c34b290..82b2e7f4a 100644 --- a/plugins/guests/suse/cap/network_scripts_dir.rb +++ b/plugins/guests/suse/cap/network_scripts_dir.rb @@ -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 diff --git a/plugins/guests/suse/cap/nfs_client.rb b/plugins/guests/suse/cap/nfs_client.rb new file mode 100644 index 000000000..36a92d201 --- /dev/null +++ b/plugins/guests/suse/cap/nfs_client.rb @@ -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 diff --git a/plugins/guests/suse/cap/rsync.rb b/plugins/guests/suse/cap/rsync.rb new file mode 100644 index 000000000..aed989613 --- /dev/null +++ b/plugins/guests/suse/cap/rsync.rb @@ -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 diff --git a/plugins/guests/suse/guest.rb b/plugins/guests/suse/guest.rb index 340f5818d..643403f19 100644 --- a/plugins/guests/suse/guest.rb +++ b/plugins/guests/suse/guest.rb @@ -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 diff --git a/plugins/guests/suse/plugin.rb b/plugins/guests/suse/plugin.rb index 0aa9bd289..3850ae45c 100644 --- a/plugins/guests/suse/plugin.rb +++ b/plugins/guests/suse/plugin.rb @@ -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 diff --git a/plugins/hosts/opensuse/host.rb b/plugins/hosts/opensuse/host.rb deleted file mode 100644 index 5e0240d27..000000000 --- a/plugins/hosts/opensuse/host.rb +++ /dev/null @@ -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 diff --git a/plugins/hosts/opensuse/plugin.rb b/plugins/hosts/opensuse/plugin.rb deleted file mode 100644 index 6ed81f8da..000000000 --- a/plugins/hosts/opensuse/plugin.rb +++ /dev/null @@ -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 diff --git a/plugins/hosts/opensuse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb similarity index 58% rename from plugins/hosts/opensuse/cap/nfs.rb rename to plugins/hosts/suse/cap/nfs.rb index d16bc9327..42bde6bb2 100644 --- a/plugins/hosts/opensuse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -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) diff --git a/plugins/hosts/suse/host.rb b/plugins/hosts/suse/host.rb new file mode 100644 index 000000000..2cc5c24c7 --- /dev/null +++ b/plugins/hosts/suse/host.rb @@ -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 diff --git a/plugins/hosts/suse/plugin.rb b/plugins/hosts/suse/plugin.rb new file mode 100644 index 000000000..3aa1b441f --- /dev/null +++ b/plugins/hosts/suse/plugin.rb @@ -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 diff --git a/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb b/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb index 278fe49a8..fd5ef1b30 100644 --- a/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb +++ b/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb @@ -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 diff --git a/plugins/provisioners/cfengine/plugin.rb b/plugins/provisioners/cfengine/plugin.rb index 4e1a7f093..ee5d75768 100644 --- a/plugins/provisioners/cfengine/plugin.rb +++ b/plugins/provisioners/cfengine/plugin.rb @@ -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