Use dnf on Fedora guests instead of yum if available.

Fixes #6286 now properly installs Docker on Fedora guests.
Fixes #6287 use dnf if available.
This commit is contained in:
Rickard von Essen 2015-09-20 09:30:49 +02:00
parent 45ab5b4dc5
commit acde6e1b16
7 changed files with 72 additions and 4 deletions

View File

@ -3,7 +3,11 @@ module VagrantPlugins
module Cap
class NFSClient
def self.nfs_client_install(machine)
if VagrantPlugins::GuestRedHat::Plugin.dnf?(machine)
machine.communicate.sudo("dnf -y install nfs-utils nfs-utils-lib")
else
machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
end
restart_nfs(machine)
end

View File

@ -4,6 +4,9 @@ module VagrantPlugins
class RSync
def self.rsync_install(machine)
machine.communicate.tap do |comm|
if VagrantPlugins::GuestRedHat::Plugin.dnf?(machine)
comm.sudo("dnf -y install rsync")
else
comm.sudo("yum -y install rsync")
end
end
@ -11,3 +14,4 @@ module VagrantPlugins
end
end
end
end

View File

@ -45,6 +45,10 @@ module VagrantPlugins
require_relative "cap/rsync"
Cap::RSync
end
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end

View File

@ -14,10 +14,20 @@ module VagrantPlugins
logger.info("Installing CFEngine Community Yum Repository GPG KEY from #{config.repo_gpg_key_url}")
comm.sudo("GPGFILE=$(mktemp) && wget -O $GPGFILE #{config.repo_gpg_key_url} && rpm --import $GPGFILE; rm -f $GPGFILE")
if dnf?(machine)
comm.sudo("dnf -y install #{config.package_name}")
else
comm.sudo("yum -y install #{config.package_name}")
end
end
end
protected
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end
end

View File

@ -6,11 +6,21 @@ module VagrantPlugins
module Redhat
module ChefInstall
def self.chef_install(machine, version, prerelease, download_path)
if dnf?(machine)
machine.communicate.sudo("dnf install -y -q curl")
else
machine.communicate.sudo("yum install -y -q curl")
end
command = Omnibus.build_command(version, prerelease, download_path)
machine.communicate.sudo(command)
end
protected
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end

View File

@ -0,0 +1,31 @@
module VagrantPlugins
module DockerProvisioner
module Cap
module Fedora
module DockerInstall
def self.docker_install(machine, version)
if version != :latest
machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported"))
end
machine.communicate.tap do |comm|
if dnf?(machine)
comm.sudo("dnf -y install docker")
else
comm.sudo("yum -y install docker")
end
comm.sudo("systemctl start docker.service")
comm.sudo("systemctl enable docker.service")
end
end
protected
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end
end
end

View File

@ -24,6 +24,11 @@ module VagrantPlugins
Cap::Debian::DockerStartService
end
guest_capability("fedora", "docker_install") do
require_relative "cap/fedora/docker_install"
Cap::Fedora::DockerInstall
end
guest_capability("redhat", "docker_install") do
require_relative "cap/redhat/docker_install"
Cap::Redhat::DockerInstall