Creating a Basic Vagrantfile

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Vagrant lets us define our desired development environment. It also leverages existing platforms such as VirtualBox and Docker to provision these environments based on how we define them. In this hands-on lab, we use Vagrant alongside LXC to create a simple Vagrantfile that provisions a single Debian host to our specifications.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Generate the Vagrantfile
  1. Create the wanderer-app directory:

    mkdir wanderer-app
  2. Move into that directory:

    cp wanderer-app/
  3. Generate a Vagrantfile:

    vagrant init
Write the Vagrantfile
  1. Write a simple Vagrantfile based on the instructions:

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    Vagrant.configure("2") do |config|
      config.vm.box = "fgrehm/wheezy64-lxc"
      config.vm.box_version = "1.2.0"
      config.vm.hostname = "wanderer"
      config.vm.provider "lxc"
    end
Test the Vagrantfile
  1. To test the Vagrantfile, run:

    vagrant up

Additional Resources

You are a DevOps Engineer in charge of creating the needed environment to test an application's infrastructure upgrade. The application is currently hosted on an LXC container. Use a specific version of Debian, while meeting the following requirements:

  • Save the environment to the cloud_user's home directory in a directory called wanderer-app.
  • In the Vagrantfile:
    • Use the lxc provider.
    • The provider is installed; it does need to be defined in the Vagrantfile.
    • Use the fgrehm/wheezy64-lxc box.
    • Lock it to version 1.2.0.
    • Set the hostname to wanderer01.

Provision the environment when finished to ensure there are no errors.

Note that when using the config.vm.provider setting, you do not include the = as if you were setting a variable.

config.vm.provider "PROVIDER"

For detailed instructions on how to complete these tasks, expand each learning objective below, or click the Guide tab above the video player.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!