Skip to content

Instantly share code, notes, and snippets.

@eduardomp
Last active May 10, 2024 00:33
Show Gist options
  • Save eduardomp/1d54b1f6cc059d6ad885fc6d8af45eca to your computer and use it in GitHub Desktop.
Save eduardomp/1d54b1f6cc059d6ad885fc6d8af45eca to your computer and use it in GitHub Desktop.
Vagrantfile - Vagrant + Ubuntu + QEMU provider tested in MacOs M1 ARM64
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "perk/ubuntu-2204-arm64"
config.vm.box_version = "20230416"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.box_check_update = false
config.vm.network "public_network"
#needed ports of Zuul
#config.vm.network :forwarded_port, host: 8080, guest: 8080
#config.vm.network :forwarded_port, host: 29418, guest: 29418
#config.vm.network :forwarded_port, host: 9000, guest: 9000
#config.vm.network :forwarded_port, host: 8005, guest: 8005
#config.vm.network :forwarded_port, host: 8005, guest: 8000
config.vm.boot_timeout = 600
config.ssh.insert_key = true
config.vm.provision "shell", inline: <<-SHELL
echo "\n *********** Setting locale language to en_US.UTF-8 *********** \n"
sudo echo "LANG=en_US.UTF-8" >> /etc/environment
sudo echo "LANGUAGE=en_US.UTF-8" >> /etc/environment
sudo echo "LC_ALL=en_US.UTF-8" >> /etc/environment
sudo echo "LC_CTYPE=en_US.UTF-8" >> /etc/environment
echo "\n *********** Updating repositories *********** \n"
sudo apt-get update
sudo apt-get -y upgrade
echo "\n *********** Installing Docker *********** \n"
sudo apt-get -y install docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker
sudo update-rc.d docker defaults
echo "\n *********** Installing podman, git, python3-pip, git-review and podman-compose *********** \n"
apt-get install podman git python3-pip -y
python3 -m pip install --upgrade pip
python3 -m pip install git-review podman-compose
echo "\n *********** Clonning Zuul *********** \n"
git clone https://opendev.org/zuul/zuul
SHELL
config.vm.provision "shell", run: "always", inline: <<-SHELL2
echo "\n *********** Starting Zuul ecosystem *********** \n"
cd zuul/doc/source/examples
podman-compose up -d
echo "\n All ready, type 'vagrant ssh' to connect into the VM! \n"
SHELL2
config.vm.provider :virtualbox do |vb|
vb.check_guest_additions = false
vb.memory = 4096
vb.cpus = 2
end
end
@eduardomp
Copy link
Author

To run this VM on MacOS with M1 (ARM64) processor, you need to install QEMU and the related plugin

brew install qemu

vagrant plugin install vagrant-qemu

vagrant up --provider qemu

@eduardomp
Copy link
Author

@pythoninthegrass
Copy link

This doesn't look like the qemu provider:

config.vm.provider :virtualbox do |vb|
  vb.check_guest_additions = false
  vb.memory = 4096
  vb.cpus = 2
end

Shouldn't it be something like this?:

config.vm.provider "qemu" do |qe|
  qe.cpu = "cortex-a72"
  qe.smp = "cpus=2,sockets=1,cores=2,threads=1"
  qe.memory = "4G"
end

@darkn3rd
Copy link

Did you get port forwarding to work? It currently will not work through the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment