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) Install Vagrant & VirtualBox.
2) 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
3) Start the VM: vagrant up
4) SSH in: vagrant ssh
5) Add the necessary firewall rules:
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --reload
6) Launch your app on 0.0.0.0:8000
, and it should be good to visit in your browser at localhost:8000
!
Member discussion