Skip to content

Instantly share code, notes, and snippets.

@versionsix
Last active July 6, 2018 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versionsix/5feca359bfee644c1897d7f68db8292a to your computer and use it in GitHub Desktop.
Save versionsix/5feca359bfee644c1897d7f68db8292a to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment