-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker provision centos8 #11462
Merged
Merged
Docker provision centos8 #11462
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9d53e8c
Recognize rhel8 flavor
soapy1 60b0542
Install containerd.io from docker on rhel_8
soapy1 f7d6070
Raise error when trying to install docker on centos8
soapy1 d87d421
Install docker using docker repo instead of convenience script
soapy1 d500dae
Support centos flavors of redhat
soapy1 311fb03
Don't install docker on RHEL
soapy1 5104d07
Add CentOS guest plugin
soapy1 e61725a
Docker provision to support centos guest, not RHEL guest
soapy1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module VagrantPlugins | ||
module GuestCentos | ||
module Cap | ||
class Flavor | ||
def self.flavor(machine) | ||
# Read the version file | ||
output = "" | ||
machine.communicate.sudo("cat /etc/centos-release") do |_, data| | ||
output = data | ||
end | ||
|
||
# Detect various flavors we care about | ||
if output =~ /(CentOS)( .+)? 7/i | ||
return :centos_7 | ||
elsif output =~ /(CentOS)( .+)? 8/i | ||
return :centos_8 | ||
else | ||
return :centos | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module VagrantPlugins | ||
module GuestCentos | ||
class Guest < Vagrant.plugin("2", :guest) | ||
def detect?(machine) | ||
machine.communicate.test("cat /etc/centos-release") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "vagrant" | ||
|
||
module VagrantPlugins | ||
module GuestCentos | ||
class Plugin < Vagrant.plugin("2") | ||
name "CentOS guest" | ||
description "CentOS guest support." | ||
|
||
guest(:centos, :redhat) do | ||
require_relative "guest" | ||
Guest | ||
end | ||
|
||
guest_capability(:centos, :flavor) do | ||
require_relative "cap/flavor" | ||
Cap::Flavor | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
...oners/docker/cap/redhat/docker_install.rb → ...oners/docker/cap/centos/docker_install.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
plugins/provisioners/docker/cap/centos/docker_start_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
plugins/provisioners/docker/cap/redhat/docker_start_service.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require_relative "../../../../base" | ||
|
||
describe "VagrantPlugins::GuestCentos::Cap::Flavor" do | ||
let(:caps) do | ||
VagrantPlugins::GuestCentos::Plugin | ||
.components | ||
.guest_capabilities[:centos] | ||
end | ||
|
||
let(:machine) { double("machine") } | ||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } | ||
|
||
before do | ||
allow(machine).to receive(:communicate).and_return(comm) | ||
end | ||
|
||
after do | ||
comm.verify_expectations! | ||
end | ||
|
||
describe ".flavor" do | ||
let(:cap) { caps.get(:flavor) } | ||
|
||
{ | ||
"CentOS Linux 2.4 release 7" => :centos_7, | ||
"CentOS Linux release 8.1.1911 (Core)" => :centos_8, | ||
|
||
"CentOS" => :centos, | ||
"banana" => :centos, | ||
}.each do |str, expected| | ||
it "returns #{expected} for #{str}" do | ||
comm.stub_command("cat /etc/centos-release", stdout: str) | ||
expect(cap.flavor(machine)).to be(expected) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will close #11453 👍