Provisioning a Red Hat VirtualBox VM With Vagrant
In what I hope will be the last entry in the "Brent learns the basics of VM provisioning" series, I finally moved to using Hashicorp's Vagrant yesterday. I'm glad I took the time to mess around in VirtualBox itself first - I always like understanding what I'm working with before I move to abstractions - but Vagrant makes it significantly easier. Vagrant sets up SSH in your VM by default, which is a nice time-saver, and generally makes the process of automating VM setup quick and easy. Behold: 1
In what I hope will be the last entry in the "Brent learns the basics of VM provisioning" series, I finally moved to using Hashicorp's Vagrant yesterday. I'm glad I took the time to mess around in VirtualBox itself first - I always like understanding what I'm working with before I move to abstractions - but Vagrant makes it significantly easier. Vagrant sets up SSH in your VM by default, which is a nice time-saver, and generally makes the process of automating VM setup quick and easy. Behold:
- Install Vagrant & VirtualBox.
- In your project folder, add the following
Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "generic/rhel9"
config.vm.box_version = "4.3.12"
config.vm.hostname = "rheldev.local"
config.vm.synced_folder "{HOST_PATH}", "{GUEST_PATH}", type: "rsync"
config.vm.provision "shell",
inline: "subscription-manager register --username={YOUR_USERNAME} --password={YOUR_PASSWORD}"
config.vm.network "forwarded_port", guest: 8000, host:8000
end- Start the VM:
vagrant up - SSH in:
vagrant ssh - Add the necessary firewall rules:
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --reload
- Launch your app on
0.0.0.0:8000, and it should be good to visit in your browser atlocalhost:8000!
Did you enjoy this article?
Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.