From 6fa0fe09ab997198a234a845efcc518638d47e2f Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:47:13 +0200 Subject: [PATCH 1/7] Renamed host capabilities from opensuse to suse --- plugins/hosts/{opensuse => suse}/cap/nfs.rb | 0 plugins/hosts/{opensuse => suse}/host.rb | 0 plugins/hosts/{opensuse => suse}/plugin.rb | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename plugins/hosts/{opensuse => suse}/cap/nfs.rb (100%) rename plugins/hosts/{opensuse => suse}/host.rb (100%) rename plugins/hosts/{opensuse => suse}/plugin.rb (100%) diff --git a/plugins/hosts/opensuse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb similarity index 100% rename from plugins/hosts/opensuse/cap/nfs.rb rename to plugins/hosts/suse/cap/nfs.rb diff --git a/plugins/hosts/opensuse/host.rb b/plugins/hosts/suse/host.rb similarity index 100% rename from plugins/hosts/opensuse/host.rb rename to plugins/hosts/suse/host.rb diff --git a/plugins/hosts/opensuse/plugin.rb b/plugins/hosts/suse/plugin.rb similarity index 100% rename from plugins/hosts/opensuse/plugin.rb rename to plugins/hosts/suse/plugin.rb From f1b62ae03a6ba9c309627fcde894ed8164d6e900 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:48:58 +0200 Subject: [PATCH 2/7] Fixed class naming and detection for suse hosts --- plugins/hosts/suse/cap/nfs.rb | 2 +- plugins/hosts/suse/host.rb | 18 +++++++++++++----- plugins/hosts/suse/plugin.rb | 14 ++++++-------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index d16bc9327..6bb17b172 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module HostOpenSUSE + module HostSUSE module Cap class NFS def self.nfs_check_command(env) diff --git a/plugins/hosts/suse/host.rb b/plugins/hosts/suse/host.rb index 5e0240d27..2cc5c24c7 100644 --- a/plugins/hosts/suse/host.rb +++ b/plugins/hosts/suse/host.rb @@ -3,14 +3,22 @@ require "pathname" require "vagrant" module VagrantPlugins - module HostOpenSUSE + module HostSUSE class Host < Vagrant.plugin("2", :host) def detect?(env) - release_file = Pathname.new("/etc/SuSE-release") + old_release_file = Pathname.new("/etc/SuSE-release") - if release_file.exist? - release_file.open("r") do |f| - return true if f.gets =~ /^openSUSE/ + 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 diff --git a/plugins/hosts/suse/plugin.rb b/plugins/hosts/suse/plugin.rb index 6ed81f8da..a2d692536 100644 --- a/plugins/hosts/suse/plugin.rb +++ b/plugins/hosts/suse/plugin.rb @@ -1,24 +1,22 @@ require "vagrant" module VagrantPlugins - module HostOpenSUSE + module HostSUSE class Plugin < Vagrant.plugin("2") - name "OpenSUSE host" - description "OpenSUSE host support." + name "SUSE host" + description "SUSE host support." - host("opensuse", "linux") do + host("suse", "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 + host_capability("suse", "nfs_check_command") do require_relative "cap/nfs" Cap::NFS end - host_capability("opensuse", "nfs_start_command") do + host_capability("suse", "nfs_start_command") do require_relative "cap/nfs" Cap::NFS end From 31b6d69127f7eb1a6ccdc5cc475f6547480f3cf0 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:51:34 +0200 Subject: [PATCH 3/7] Fixed suse naming for fcengine cap and refined install command --- plugins/provisioners/cfengine/cap/suse/cfengine_install.rb | 7 ++++--- plugins/provisioners/cfengine/plugin.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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 From 6c20b6cd34eaa7602994b20b6264b8727e33b95f Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:52:15 +0200 Subject: [PATCH 4/7] Fixed suse spelling in fedora capability --- plugins/guests/fedora/cap/network_scripts_dir.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 063a903bdb2cde1a28da6f35e3db3be118807fdf Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:52:58 +0200 Subject: [PATCH 5/7] 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 :). --- plugins/guests/suse/cap/change_host_name.rb | 5 ++-- plugins/guests/suse/cap/configure_networks.rb | 2 +- plugins/guests/suse/cap/halt.rb | 2 +- .../guests/suse/cap/network_scripts_dir.rb | 4 +-- plugins/guests/suse/cap/nfs_client.rb | 16 ++++++++++ plugins/guests/suse/cap/rsync.rb | 17 +++++++++++ plugins/guests/suse/guest.rb | 4 +-- plugins/guests/suse/plugin.rb | 29 ++++++++++++++----- 8 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 plugins/guests/suse/cap/nfs_client.rb create mode 100644 plugins/guests/suse/cap/rsync.rb 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 From 2d4454dcb486e76225e56cbe0b33aa2659b464c2 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 17:44:28 +0200 Subject: [PATCH 6/7] Added a nonsudo command for nfsd check --- plugins/hosts/suse/cap/nfs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index 6bb17b172..facaa68ae 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -3,7 +3,7 @@ module VagrantPlugins module Cap class NFS def self.nfs_check_command(env) - "/sbin/service nfsserver status" + "pidof nfsd > /dev/null" end def self.nfs_start_command(env) From 95f39d52faa3c90f161548a9152cee14d0171416 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 6 Oct 2014 16:32:00 +0200 Subject: [PATCH 7/7] Added better check if nfs server is available on SUSE hosts --- plugins/hosts/suse/cap/nfs.rb | 4 ++++ plugins/hosts/suse/plugin.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index facaa68ae..42bde6bb2 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -2,6 +2,10 @@ module VagrantPlugins 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) "pidof nfsd > /dev/null" end diff --git a/plugins/hosts/suse/plugin.rb b/plugins/hosts/suse/plugin.rb index a2d692536..3aa1b441f 100644 --- a/plugins/hosts/suse/plugin.rb +++ b/plugins/hosts/suse/plugin.rb @@ -11,6 +11,11 @@ module VagrantPlugins 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