Skip to content

Commit

Permalink
Add option to install from kubic
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Apr 3, 2020
1 parent 42785cb commit 82614cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
34 changes: 18 additions & 16 deletions plugins/provisioners/podman/cap/redhat/podman_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ module PodmanProvisioner
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|
Expand Down
12 changes: 12 additions & 0 deletions plugins/provisioners/podman/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
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"
Expand Down
4 changes: 2 additions & 2 deletions plugins/provisioners/podman/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class Installer < VagrantPlugins::ContainerProvisioner::Installer
# wrong.
# @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
end

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)
Expand Down
3 changes: 2 additions & 1 deletion plugins/provisioners/podman/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def initialize(machine, config, installer = nil, client = nil)

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 = {
Expand Down

0 comments on commit 82614cf

Please sign in to comment.