TeamSnap Logo
Log inFind My Team
  • Solutions
    • For Business
      For Business

      Tools for clubs, leagues, tournament organizers, and associations to run their business

      For Teams
      For Teams

      For coaches, players & fans to stay connected on our top-rated mobile app

      Promo image
      • Overview
      • Program ManagementManage all aspects of your organization
      • SponsorshipAccess our network of opportunities
      • RegistrationPayments, dues, and more
      • TournamentsBuild and manage your events
      • PaymentsA better way to manage payments
      • Website BuilderProfessional & mobile friendly sites
      • SchedulingAutomate games & practices
      • Services & SupportIndustry-leading account support
      • MessagesSimple, reliable communication
      • Get started!Chat with our team right now
  • Pricing
  • Resources
    • Community

      Our mission is to enhance the lives of kids by enabling participation in sport

        Other resources
        • Blog
        • Coaches’ Corner
        • For Business Resources
        • TeamSnap Updates
        • Help Center
        Company
        • About
        • Careers
        • Partners
    • For Brands
      • Build relationships in the moments that matter.

        Convert families into superfans with TeamSnap for brands.

          • OverviewThe #1 way to reach the Chief Household Officer
          • AudienceLearn about our audience and network
          • CapabilitiesExplore our products and measurement solutions
          • Download Media Kit

      Find My Team

      Sign upLog in
      Sign upLog in
      • Home
      • Ruby SDK
      • API
      • API Help / Feedback
      Blog/ DevOps / Vagrant - A Developer's Best Friend…

      Vagrant - A Developer's Best Friend

      Image of engineering blog author: Tyler KnappeTyler Knappe
      • DevOps
      • Vagrant
      • Ruby

      Vagrant - A Developer's Best Friend

      Have you ever broken your development environment and dreaded of the hours it will take to rebuild your environment? I certainly have, on multiple occasions. This is where Vagrant comes to the rescue! Vagrant is an excellent tool to build disposable, lightweight development environments. It leverages the power of Virtual Machines (VM) to allow you to easily build customizable images, so you can quickly bring up a custom environment.

      To start, simply download the Vagrant client and a 'provider' like VirtualBox or VMware. I would recommend you use VirtualBox as your provider as we start out, as it is free and works on every OS. I'll assume we're using VirtualBox from here on out.

      After having installed both Vagrant and a provider, you can start the Virtual Machine with two commands:

      $ vagrant init hashicorp/precise32
      $ vagrant up
      

      That's it! You now have a VM running. Specifically it is using the image hashicorp/precise32 which is built on Ubuntu 12.04 LTS 32bit.

      Vagrantfile

      I mentioned that you can customize your environment and this is where a Vagrantfile comes in to play. A Vagrantfile is simply a bunch of Ruby commands used to configure the VM. You can generate a Vagrantfile with the command vagrant init. If you poke around in the file, you'll notice that is has a bunch of sample configuration that can be used to further customize the VM.

      One important block you'll see is the config.vm.provision line. This is where the magic happens! Here is where you can customize your VM to install various pieces of software, run setup scripts or, really, do whatever you want. You can see some of the most basic examples look like

        config.vm.provision "shell" do |s|
          s.inline = "echo hello"
        end
      

      This will simply spawn a shell when the VM is provisioned and run the command echo hello on the VM. The implications are very exciting! From here, you can use a provision block to invoke package managers, run external scripts or even invoke other build management tools like ansible or chef.

      Networking

      Now that you have your VM customized, you'll want to be able to access it from the outside world. This is where config.vm.network comes into play. For example, if I want to make port 80 on my VM accessible, I can simply put the following inside of my Vagrant.configure block:

        config.vm.network "forwarded_port", guest: 80, host: 8080
      

      This will forward port 80 on my guest (VM) to port 8080 on my host (machine running vagrant). You can port forward to your heart's content, allowing various services access to the outside world.

      There are some other networking options, like setting up private and public networks, check the documentation for more info.

      Synced Folders

      One of the other niceties of Vagrant is the ability to sync folders across machines. This makes it easy to transfer files back and forth without the need and hassle of using commands like scp and also means you can write your code on your host, using a graphical editor, perhaps, and run the code on the guest. To set this up for a VirtualBox Provider:

        config.vm.synced_folder "src/", "/srv/website"
      

      This will sync files from src/ on the host to /srv/website on the VM. One of the niceties of Vagrant and VirtualBox is that you actually get this functionality for free. If you do an ls of /vagrant you should see all of the files from the host where you you ran vagrant up. There are further instructions on synced folders here.

      The above should get you started on building your custom development environment! Feel free to read up on Vagrant here to get a better feel for the power of being able to build your own custom development environments.

      Products
      Sports Organizations
      • Get a demo
      • Features
      • Pricing
      • Tournaments
      • FAQs
      Coaches or Team Managers
      • Features
      • Pricing
      • Tournaments
      • Get Started
      Parents or Athletes
      • Features
      • Pricing
      • Find My Team
      • Get Started
      Sports
      Sports Organizations
      • Baseball
      • Basketball
      • Football
      • Ice Hockey
      • Lacrosse
      • Soccer
      • Softball
      • Volleyball
      Teams
      • Baseball
      • Basketball
      • Football
      • Ice Hockey
      • Soccer
      • Softball
      • +100s more
      Resources
      • Blog
      • Coaches’ Corner
      • Return To Play
      • For Business Resource Library
      • Skills & Drills
      • Press Releases
      • TeamSnap Updates
      • TeamSnap Help Center
      • Community
      • Why TeamSnap?
      Company
      • About
      • CareersHiring!
      • For Brands
      • Partners
      • TeamSnap API
      • Responsible Disclosure Policy
      • Youth sports team and sports org app Apple App Store Logo
      • Youth sports team and sports org app Google Play Store Logo
      • social-media-facebook
      • social-media-twitter
      • social-pinterest
      • social-instagram
      • social-video-youtube
      • professional-network-linkedin
      • social-tiktok

      TeamSnap Footer Logo

      Copyright © 2005–2023 TeamSnap, Inc.

      • Sitemap
      • Terms
      • Privacy Policy
      • California Privacy Policy
      • Your Privacy Choices