mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
3.8 KiB
3.8 KiB
Vagrant
TL;DR
# start a box
vagrant up
# connect to the box
vagrant ssh
# print the ssh config snippet to connect to the box
vagrant ssh-config
# (re)provision a box
vagrant provision
vagrant up --provision
# add a box
vagrant add archlinux/archlinux
vagrant add debian/testing64 --provider virtualbox
# list downloaded boxes
vagrant box list
# list outdated boxes
vagrant box outdated
# update a box
vagrant box update
vagrant box update --box generic/gentoo
# remove a box
vagrant box remove archlinux/archlinux
# install autocomplete
vagrant autocomplete install --bash
vagrant autocomplete install --zsh
# install a plugin
vagrant plugin install vagrant-disksize
Usage
-
install using your package manager
-
create a box:
[home]$ mkdir -p "~/vagrant/archlinux" [home]$ cd "${_}" [archlinux]$ vagrant init archlinux/archlinux -
start the box:
[archlinux]$ vagrant up # re-run provisioning [archlinux]$ vagrant up --provision -
connect to the machine:
[archlinux]$ vagrant ssh
Install autocomplete
$ vagrant autocomplete install --bash
Autocomplete installed at paths:
- /home/user/.bashrc
$ vagrant autocomplete install --zsh
Autocomplete installed at paths:
- /home/user/.zshrc
Boxes management
vagrant box add archlinux/archlinux
vagrant box add archlinux/archlinux --provider virtualbox
vagrant box list
vagrant box update
vagrant box update --box generic/gentoo
Customize VM settings
Vagrant.configure("2") do |config|
config.vm.box = "archlinux/archlinux"
config.vm.provider "virtualbox" do |vb|
vb.memory = "3072"
vb.customize ["modifyvm", :id, "--vram", "64"]
vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
end
Use environment variables in the provisioning script
Add the variables as argument of the config.vm.provision key:
Vagrant.configure("2") do |config|
config.vm.provision "shell", env: { "KEYBASE_USERNAME" => ENV['KEYBASE_USERNAME'], "KEYBASE_PAPERKEY" => ENV['KEYBASE_PAPERKEY'] }, inline: <<-SHELL
pacman -Sy --noconfirm --noprogressbar \
fzf zsh-completions \
keybase
pacman -Scc --noconfirm
chsh --shell /bin/zsh vagrant
sudo --user vagrant --preserve-env=KEYBASE_USERNAME,KEYBASE_PAPERKEY keybase oneshot
sudo --user vagrant --preserve-env=KEYBASE_USERNAME,KEYBASE_PAPERKEY keybase git list
SHELL
end
Specify the disk size
Install the vagrant-disksize plugin:
vagrant plugin install vagrant-disksize
then set it up:
vagrant.configure('2') do |config|
config.disksize.size = '50GB'
end
Reboot after provision
Add this to the Vagrantfile:
config.vm.provision "shell", reboot: true