Skip to content

Instantly share code, notes, and snippets.

@mmguero
Created May 12, 2021 22:00
Show Gist options
  • Save mmguero/747745c72274994e2e4d7dde860308c3 to your computer and use it in GitHub Desktop.
Save mmguero/747745c72274994e2e4d7dde860308c3 to your computer and use it in GitHub Desktop.
Vagrantfile for Ubuntu 21.04 with Docker already set up (and a second user with a 1001 UID)
# hack: https://github.com/hashicorp/vagrant/issues/8878#issuecomment-345112810
class VagrantPlugins::ProviderVirtualBox::Action::Network
def dhcp_server_matches_config?(dhcp_server, config)
true
end
end
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-21.04"
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder "~/tmp", "/host"
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
vb.cpus = 2
end
config.vm.provision "shell", inline: <<-STEP1
export DEBIAN_FRONTEND=noninteractive
apt-get -qqy update
apt-get -y install --no-install-recommends \
git curl jq moreutils apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get -qqy update
apt-get -y install docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod 755 /usr/local/bin/docker-compose
usermod -a -G docker vagrant
adduser --shell /bin/bash --uid 1001 mmguero
usermod -a -G docker mmguero
usermod -a -G sudo mmguero
echo -e "mmguero\nmmguero" | passwd mmguero
for VUSER in vagrant mmguero; do
mkdir -p /home/$VUSER/.local/bin /home/$VUSER/.config /home/$VUSER/bin /home/$VUSER/tmp
touch /home/$VUSER/.hushlogin
echo "set nocompatible" > /home/$VUSER/.vimrc
git clone --recursive --single-branch --depth 1 https://github.com/mmguero/config /home/$VUSER/.config/mmguero.config
rm -f /home/$VUSER/.bashrc
ln -s -f -r /home/$VUSER/.config/mmguero.config/bash/rc /home/$VUSER/.bashrc
ln -s -f -r /home/$VUSER/.config/mmguero.config/bash/rc.d /home/$VUSER/.bashrc.d
ln -s -f -r /home/$VUSER/.config/mmguero.config/bash/aliases /home/$VUSER/.bash_aliases
ln -s -f -r /home/$VUSER/.config/mmguero.config/bash/functions /home/$VUSER/.bash_functions
ln -s -f -r /home/$VUSER/.config/mmguero.config/bash/context-color/context-color /home/$VUSER/.local/bin/context-color
ln -s -f -r /home/$VUSER/.config/mmguero.config/linux/tmux/tmux.conf /home/$VUSER/.tmux.conf
ln -s -f -r /home/$VUSER/.config/mmguero.config/git/gitconfig /home/$VUSER/.gitconfig
chown -R $VUSER:$VUSER /home/$VUSER
done
STEP1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment