Last active
July 6, 2018 12:05
-
-
Save versionsix/5feca359bfee644c1897d7f68db8292a to your computer and use it in GitHub Desktop.
Vagrant add local updated centos7 image
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
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment