xenefix
7/6/2018 - 11:35 AM

Vagrant add local updated centos7 image

Vagrant add local updated centos7 image

#!/bin/bash
# Based on https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one
mkdir -p centos7_box
cd centos7_box

touch Vagrantfile
cat << EOF > Vagrantfile
Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  config.vm.box = "centos/7"
  config.vm.box_check_update = true
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
    vb.cpus = 2
  end
  config.vm.provision "shell", inline: <<-SHELL
    yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    yum update -y
    yum install ansible -y
    sudo dd if=/dev/zero of=/EMPTY bs=1M
    sudo rm -f /EMPTY
    cat /dev/null > ~/.bash_history && history -c
  SHELL
end
EOF

vagrant up
vagrant package --output centos7.box
vagrant box add centos7 centos7.box --force

vagrant destroy --force
cd ..
rm -rf centos7_box