Skip to content

Commit

Permalink
Docker provision to support centos guest, not RHEL guest
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Apr 6, 2020
1 parent 5104d07 commit e61725a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
module VagrantPlugins
module DockerProvisioner
module Cap
module Redhat
module Centos
module DockerInstall
def self.docker_install(machine)
flavor = machine.guest.capability("flavor")
if flavor.to_s.include? "rhel"
# rhel is not supported by docker ce
# https://docs.docker.com/ee/docker-ee/rhel/
machine.ui.warn(I18n.t("vagrant.provisioners.docker.rhel_not_supported"))
raise DockerError, :install_failed
end

machine.communicate.tap do |comm|
comm.sudo("yum -q -y update")
comm.sudo("yum -q -y remove docker-io* || true")
Expand All @@ -21,22 +13,22 @@ def self.docker_install(machine)
comm.sudo("yum install -y -q docker-ce")
end

case flavor
when :centos_7
docker_enable_centos7(machine)
case machine.guest.capability("flavor")
when :centos
docker_enable_service(machine)
else
docker_enable_default(machine)
docker_enable_systemctl(machine)
end
end

def self.docker_enable_centos7(machine)
def self.docker_enable_systemctl(machine)
machine.communicate.tap do |comm|
comm.sudo("systemctl start docker.service")
comm.sudo("systemctl enable docker.service")
end
end

def self.docker_enable_default(machine)
def self.docker_enable_service(machine)
machine.communicate.tap do |comm|
comm.sudo("service docker start")
comm.sudo("chkconfig docker on")
Expand Down
24 changes: 24 additions & 0 deletions plugins/provisioners/docker/cap/centos/docker_start_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module VagrantPlugins
module DockerProvisioner
module Cap
module Centos
module DockerStartService
def self.docker_start_service(machine)
case machine.guest.capability("flavor")
when :centos
machine.communicate.tap do |comm|
comm.sudo("service docker start")
comm.sudo("chkconfig docker on")
end
else
machine.communicate.tap do |comm|
comm.sudo("systemctl start docker.service")
comm.sudo("systemctl enable docker.service")
end
end
end
end
end
end
end
end
16 changes: 0 additions & 16 deletions plugins/provisioners/docker/cap/redhat/docker_start_service.rb

This file was deleted.

8 changes: 4 additions & 4 deletions plugins/provisioners/docker/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class Plugin < Vagrant.plugin("2")
Cap::Fedora::DockerInstall
end

guest_capability("redhat", "docker_install") do
guest_capability("centos", "docker_install") do
require_relative "cap/redhat/docker_install"
Cap::Redhat::DockerInstall
Cap::Centos::DockerInstall
end

guest_capability("redhat", "docker_start_service") do
guest_capability("centos", "docker_start_service") do
require_relative "cap/redhat/docker_start_service"
Cap::Redhat::DockerStartService
Cap::Centos::DockerStartService
end

guest_capability("linux", "docker_installed") do
Expand Down
3 changes: 0 additions & 3 deletions templates/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2821,9 +2821,6 @@ en:
provisioner
not_running: "Docker is not running on the guest VM."
install_failed: "Docker installation failed."
rhel_not_supported: |-
RHEL is now only supported by Docker EE. Please install Docker EE or
switch to the Podman provisioner to run containers on RHEL.

salt:
minion_config_nonexist: |-
Expand Down

0 comments on commit e61725a

Please sign in to comment.