![]() ![]() I'd like to dig into Ansible, and provision machines using a playbook. It's definitely a little bit of a process to set up (though nowhere near as involved as dual booting Ubuntu, or as expensive as buying a new computer), and I can foresee issues with getting confused about shared folders or which OS they're working in, but I'm really excited to save some of the Windows users from the nightmare of configuring their computers for a curriculum that was developed entirely for UNIX environments. Everything gets reliably set up, and then we're working with exactly the environment we want! We just run vagrant up, and everything else takes care of itself.Īll in all, this process is super nice, because I only have to package and pass around the Vagrantfile and bootstrap.sh script, which are only a few lines each, rather than a 500-800MB behemoth. The Vagrantfile references a bootstrap.sh script file that is simply a list of bash commands that will install and configure stuff for us.Īs you can see, we're mostly adding PPAs and installing stuff, with the addition of a couple of operations where we're creating a user for our PostgreSQL installation and a data folder for our MongoDB. We can use a tool like Ansible for this (and I'll move over to it eventually), but I opted for a simple bash script, which is what we're doing when we see the line config.vm.provision :shell, path: "bootstrap.sh". Rather than packaging everything together, we can simply have a set of scripts that will automatically install our utilities when we first set up our VM. The alternative to this is that we "provision" our machine automatically. This is a nice idea, but it means that we'll have to upload the image somewhere, and download the whole thing every time we want to get another machine set up. Well, one thing we can do is package our entire VM image as a box. But, one of the things that appealed to me about VMs is that they let you set up an environment exactly the way that you want it. ![]() I was installing stuff on it, even using vim within the VM to edit and write code. So, initially when I installed Vagrant and spun up a VM, I was using it pretty much the same way that I used my actual Linux box. So, the config.vm.box tells us what OS to use, the config.vm.network tells us how to deal with networking - but what does the config.vm.provision do? Well, to answer that question, I'll tell you about how I ended up settling on it. ![]() The important thing is that if we need to forward additional ports, we can do so inside of this file, following the same syntax we've already got. I'm sure there's a way for me to loop over and forward an array of ports, but I'll work that out later. I'm also forwarding ports 3000, 5432, 8000, 8080, and 27017, which are for web servers, except for 547, which are for PostgreSQL and MongoDB respectively.Įnter fullscreen mode Exit fullscreen mode ![]() In my case, I want to use it for webdev, so I'm starting with an Ubuntu 18.04 installation (as opposed to a Windows one). You create a Vagrantfile, which defines the behavior of your VM. The process of using Vagrant is pretty simple. I used Vagrant with VirtualBox, which I hear isn't ideal for heavy lifting- but hey, we'll use Docker if we need better performance. (it's here if you want to check it out or give feedback!) Dealing with PostgreSQL, MongoDB, Docker, and filesystem operations in a place where people are split between Windows and UNIX-like environments is a total pain, and WSL isn't fully mature, so I decided to prepare a VM that would allow them to develop MERN stack applications with minimal fuss. At my job, we've been having a lot of issues with students having misconfigured / incompatible (or annoying to set up) hardware. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |