diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a6b54e5..8d3afeee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ BUG FIXES: - guests/linux: Show more verbose error when shared folder mount fails. [GH-4403] - guests/redhat: NFS setup should use systemd for RH7+ [GH-4228] + - guests/redhat: Detect RHEL 7 (and CentOS) and install Docker properly. [GH-4402] - guests/smartos: Use `pfexec` for rsync. [GH-4274] - guests/windows: Reboot after hostname change. [GH-3987] - hosts/arch: NFS works with latest versions. [GH-4224] diff --git a/plugins/guests/redhat/cap/flavor.rb b/plugins/guests/redhat/cap/flavor.rb new file mode 100644 index 000000000..f7ff15140 --- /dev/null +++ b/plugins/guests/redhat/cap/flavor.rb @@ -0,0 +1,23 @@ +module VagrantPlugins + module GuestRedHat + module Cap + class Flavor + def self.flavor(machine) + # Read the version file + output = "" + machine.communicate.sudo("cat /etc/redhat-release") do |type, data| + output += data if type == :stdout + end + output.chomp! + + # Detect various flavors we care about + if output =~ /(CentOS|Red Hat Enterprise) Linux release 7/i + return :rhel_7 + else + return :rhel + end + end + end + end + end +end diff --git a/plugins/guests/redhat/plugin.rb b/plugins/guests/redhat/plugin.rb index 56e6b8031..f7a255599 100644 --- a/plugins/guests/redhat/plugin.rb +++ b/plugins/guests/redhat/plugin.rb @@ -21,6 +21,11 @@ module VagrantPlugins Cap::ConfigureNetworks end + guest_capability("redhat", "flavor") do + require_relative "cap/flavor" + Cap::Flavor + end + guest_capability("redhat", "network_scripts_dir") do require_relative "cap/network_scripts_dir" Cap::NetworkScriptsDir diff --git a/plugins/provisioners/docker/cap/redhat/docker_install.rb b/plugins/provisioners/docker/cap/redhat/docker_install.rb index a0ef03cb0..fbf8e2451 100644 --- a/plugins/provisioners/docker/cap/redhat/docker_install.rb +++ b/plugins/provisioners/docker/cap/redhat/docker_install.rb @@ -8,6 +8,23 @@ module VagrantPlugins machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported")) end + case machine.guest.capability("flavor") + when :rhel_7 + docker_install_rhel7(machine) + else + docker_install_default(machine) + end + end + + def docker_install_rhel7(machine) + machine.communicate.tap do |comm| + comm.sudo("yum -y install docker") + comm.sudo("systemctl start docker.service") + comm.sudo("systemctl enable docker.service") + end + end + + def docker_install_default(machine) machine.communicate.tap do |comm| if ! comm.test("rpm -qa | grep epel-release") comm.sudo("rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm")