virtuallypotato/content/posts/manage-vms-with-vagrant-on-chromebook/index.md

3.6 KiB

title date description featured draft toc usePageBundles codeLineNumbers series tags comment
Manage VMs With HashiCorp Vagrant on a Chromebook 2023-02-18T17:22:02-06:00 Pairing the powerful Linux Development Environment on modern Chromebooks with HashiCorp Vagrant for managing local virtual machines for development and testing false true true true false Projects
linux
chromeos
homelab
infrastructure-as-code
true

I've lately been trying to do more with Salt at work, but I'm still very much a novice with that tool. I thought it would be great to have a nice little lab environment where I could deploy a few lightweight VMs and practice managing them with Salt - without impacting any systems that are actually being used for anything. I thought it might be fun to create and manage the VMs with HashiCorp Vagrant, and ultimately provision them with HashiCorp Terraform. That would give me the tools for quickly creating and destroying a full lab environment in short order.

Also, because I'm a bit of a sadist, I wanted to do this all on my new Framework Chromebook. I might as well put my 32GB of RAM to good use, right? It took a bit of fumbling, but this article describes what it took to get a Vagrant VM up and running in the Linux Development Environment on my Chromebook (which is currently running ChromeOS v111 beta).

Prereqs:

sudo apt update
sudo apt install \
  build-essential \
  gpg \
  lsb-release \
  wget

Install libvirt-related prereqs:

sudo apt install virt-manager libvirt-dev

Add self to libvirt group:

sudo gpasswd -a $USER libvirt ; newgrp libvirt

Add HashiCorp repo:

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

Install vagrant and plugins:

sudo apt update
sudo apt install vagrant
vagrant plugin install vagrant-libvirt

Prepare a Vagrant directory:

mkdir vagrant-bullseye
cd vagrant-bullseye
vagrant init debian/bullseye64

Install rsync:

sudo apt install rsync

Enable rsync (and disable NFS, which isn't supported within LXD) for Vagrant by editing the Vagrantfile to include:

  config.nfs.verify_installed = false
  config.vm.synced_folder '.', '/vagrant', type: 'rsync'

Start the VM:

vagrant up

Log in:

vagrant ssh