Rewrite Red Hat nfs caps based on systemd checks

This commit is contained in:
Josef Stribny 2015-06-30 10:21:58 +02:00
parent 28a42122b8
commit c4733a02d4
2 changed files with 26 additions and 8 deletions

View File

@ -3,14 +3,27 @@ module VagrantPlugins
module Cap
class NFSClient
def self.nfs_client_install(machine)
machine.communicate.tap do |comm|
comm.sudo("yum -y install nfs-utils nfs-utils-lib")
case machine.guest.capability("flavor")
when :rhel_7
comm.sudo("/bin/systemctl restart rpcbind nfs")
else
comm.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart")
end
machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
restart_nfs(machine)
end
def self.nfs_client_installed(machine)
installed = machine.communicate.test("test -x /sbin/mount.nfs")
restart_nfs(machine) if installed
installed
end
protected
def self.systemd?
`ps -o comm= 1`.chomp == 'systemd'
end
def self.restart_nfs(machine)
if systemd?
machine.communicate.sudo("/bin/systemctl restart rpcbind nfs")
else
machine.communicate.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart")
end
end
end

View File

@ -36,6 +36,11 @@ module VagrantPlugins
Cap::NFSClient
end
guest_capability("redhat", "nfs_client_installed") do
require_relative "cap/nfs_client"
Cap::NFSClient
end
guest_capability("redhat", "rsync_install") do
require_relative "cap/rsync"
Cap::RSync