Rewrite Red Hat nfs caps based on systemd checks
This commit is contained in:
parent
28a42122b8
commit
c4733a02d4
|
@ -3,14 +3,27 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class NFSClient
|
class NFSClient
|
||||||
def self.nfs_client_install(machine)
|
def self.nfs_client_install(machine)
|
||||||
machine.communicate.tap do |comm|
|
machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
|
||||||
comm.sudo("yum -y install nfs-utils nfs-utils-lib")
|
restart_nfs(machine)
|
||||||
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
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,6 +36,11 @@ module VagrantPlugins
|
||||||
Cap::NFSClient
|
Cap::NFSClient
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("redhat", "nfs_client_installed") do
|
||||||
|
require_relative "cap/nfs_client"
|
||||||
|
Cap::NFSClient
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability("redhat", "rsync_install") do
|
guest_capability("redhat", "rsync_install") do
|
||||||
require_relative "cap/rsync"
|
require_relative "cap/rsync"
|
||||||
Cap::RSync
|
Cap::RSync
|
||||||
|
|
Loading…
Reference in New Issue