Skip to content

Commit

Permalink
guest: redhat: handle missing el8 version detection in vagrant
Browse files Browse the repository at this point in the history
See hashicorp/vagrant#11453. Here we add a
compatibility function to handle :rhel_8 because otherwise we'd have
to wait until a new version of vagrant got released and rolled out
everywhere before our users could take advantage of this.
  • Loading branch information
dustymabe committed Mar 15, 2020
1 parent ac732ac commit de0dfd7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/vagrant-sshfs/cap/guest/redhat/sshfs_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ module GuestRedHat
module Cap
class SSHFSClient
def self.sshfs_install(machine)
case machine.guest.capability("flavor")

rhel_version = machine.guest.capability("flavor")

# Handle the case where Vagrant doesn't yet know how to
# detect and return :rhel_8 https://github.com/hashicorp/vagrant/pull/11453
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new('2.2.8')
rhel_version = vagrant_lt_228_flavor_compat(machine)
end

case rhel_version
when :rhel_8
# No need to install epel. fuse-sshfs comes from the PowerTools repo
# https://bugzilla.redhat.com/show_bug.cgi?id=1758884
Expand All @@ -30,6 +39,23 @@ def self.epel_installed(machine)
def self.epel_install(machine)
machine.communicate.sudo("yum -y install epel-release")
end

def self.vagrant_lt_228_flavor_compat(machine)
# This is a compatibility function to handle RHEL8 for
# vagrant versions that didn't include:
# https://github.com/hashicorp/vagrant/pull/11453
output = ""
machine.communicate.sudo("cat /etc/redhat-release") do |_, data|
output = data
end
if output =~ /(CentOS|Red Hat Enterprise|Scientific|Cloud|Virtuozzo)\s*Linux( .+)? release 8/i
return :rhel_8
elsif output =~ /(CentOS|Red Hat Enterprise|Scientific|Cloud|Virtuozzo)\s*Linux( .+)? release 7/i
return :rhel_7
else
return :rhel
end
end
end
end
end
Expand Down

0 comments on commit de0dfd7

Please sign in to comment.