Add option to install from kubic
This commit is contained in:
parent
42785cb254
commit
bcce2f720d
@ -3,22 +3,24 @@ module VagrantPlugins
|
||||
module Cap
|
||||
module Redhat
|
||||
module PodmanInstall
|
||||
def self.podman_install(machine)
|
||||
# Official install instructions for podman
|
||||
# https://podman.io/getting-started/installation.html
|
||||
case machine.guest.capability("flavor")
|
||||
when :rhel_7
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_7/devel:kubic:libcontainers:stable.repo")
|
||||
comm.sudo("yum -q -y install podman")
|
||||
end
|
||||
when :rhel_8
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("dnf -y module disable container-tools")
|
||||
comm.sudo("dnf -y install 'dnf-command(copr)'")
|
||||
comm.sudo("dnf -y copr enable rhcontainerbot/container-selinux")
|
||||
comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8/devel:kubic:libcontainers:stable.repo")
|
||||
comm.sudo("dnf -y install podman")
|
||||
def self.podman_install(machine, kubic)
|
||||
if kubic
|
||||
# Official install instructions for podman
|
||||
# https://podman.io/getting-started/installation.html
|
||||
case machine.guest.capability("flavor")
|
||||
when :rhel_7
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_7/devel:kubic:libcontainers:stable.repo")
|
||||
comm.sudo("yum -q -y install podman")
|
||||
end
|
||||
when :rhel_8
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("dnf -y module disable container-tools")
|
||||
comm.sudo("dnf -y install 'dnf-command(copr)'")
|
||||
comm.sudo("dnf -y copr enable rhcontainerbot/container-selinux")
|
||||
comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8/devel:kubic:libcontainers:stable.repo")
|
||||
comm.sudo("dnf -y install podman")
|
||||
end
|
||||
end
|
||||
else
|
||||
machine.communicate.tap do |comm|
|
||||
|
||||
@ -3,6 +3,18 @@ require_relative "../container/config"
|
||||
module VagrantPlugins
|
||||
module PodmanProvisioner
|
||||
class Config < VagrantPlugins::ContainerProvisioner::Config
|
||||
attr_accessor :kubic
|
||||
|
||||
def initialize
|
||||
super()
|
||||
@kubic = UNSET_VALUE
|
||||
end
|
||||
|
||||
def finalize!
|
||||
super()
|
||||
@kubic = false if @kubic == UNSET_VALUE
|
||||
end
|
||||
|
||||
def post_install_provision(name, **options, &block)
|
||||
# Abort
|
||||
raise PodmanError, :wrong_provisioner if options[:type] == "podman"
|
||||
|
||||
@ -6,9 +6,12 @@ module VagrantPlugins
|
||||
# This handles verifying the Podman installation, installing it if it was
|
||||
# requested, and so on. This method will raise exceptions if things are
|
||||
# wrong.
|
||||
# @params [Boolean] - if true install should use kubic project (this will)
|
||||
# add a yum repo.
|
||||
# if false install comes from default yum
|
||||
# @return [Boolean] - false if podman cannot be detected on machine, else
|
||||
# true if podman installs correctly or is installed
|
||||
def ensure_installed
|
||||
def ensure_installed(kubic)
|
||||
if !@machine.guest.capability?(:podman_installed)
|
||||
@machine.ui.warn("Podman can not be installed")
|
||||
return false
|
||||
@ -16,7 +19,7 @@ module VagrantPlugins
|
||||
|
||||
if !@machine.guest.capability(:podman_installed)
|
||||
@machine.ui.detail("Podman installing")
|
||||
@machine.guest.capability(:podman_install)
|
||||
@machine.guest.capability(:podman_install, kubic)
|
||||
end
|
||||
|
||||
if !@machine.guest.capability(:podman_installed)
|
||||
|
||||
@ -20,7 +20,8 @@ module VagrantPlugins
|
||||
|
||||
def provision
|
||||
@logger.info("Checking for Podman installation...")
|
||||
if @installer.ensure_installed
|
||||
|
||||
if @installer.ensure_installed(config.kubic)
|
||||
if !config.post_install_provisioner.nil?
|
||||
@logger.info("Running post setup provision script...")
|
||||
env = {
|
||||
|
||||
@ -49,6 +49,7 @@ describe VagrantPlugins::PodmanProvisioner::Provisioner do
|
||||
it "invokes a post_install_provisioner if defined and podman is installed" do
|
||||
allow(installer).to receive(:ensure_installed).and_return(true)
|
||||
allow(config).to receive(:post_install_provisioner).and_return(provisioner)
|
||||
allow(config).to receive(:kubic).and_return(false)
|
||||
allow(machine).to receive(:env).and_return(iso_env)
|
||||
allow(machine.env).to receive(:hook).and_return(true)
|
||||
|
||||
@ -59,6 +60,7 @@ describe VagrantPlugins::PodmanProvisioner::Provisioner do
|
||||
it "does not invoke post_install_provisioner if not defined" do
|
||||
allow(installer).to receive(:ensure_installed).and_return(true)
|
||||
allow(config).to receive(:post_install_provisioner).and_return(nil)
|
||||
allow(config).to receive(:kubic).and_return(false)
|
||||
allow(machine).to receive(:env).and_return(iso_env)
|
||||
allow(machine.env).to receive(:hook).and_return(true)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user