Skip to content

Add Vagrantfile #1

@Elwafi-Elmehdi

Description

@Elwafi-Elmehdi

Hey, @Irrenium hope you are doing great here is a simple vagrant file to get you started with vagrant.

Make sure to save the code below to a file named Vagrantfile

# Spine up an Ubuntu 20.04 Box

# Script to update the box and write a hello message to user home dir
SCRIPT = <<EOF
#!/usr/bin/env bash

sudo apt-get update

sudo apt-get -y upgrade

echo "Hello from Vagrant" >> /home/vagrant/sample.txt

EOF
Vagrant.configure("2") do |config|
   config.vm.box = "ubuntu/focal64"
   # pass script to the shell provisioner as inline script
   config.vm.provision :shell, :inline => SCRIPT, :privileged => false

   config.vm.provider "virtualbox" do |vb|
     vb.memory = "1024"
     vb.name = "ubuntu-20.04"
   end
end

After creating the file you can run (assuming you already installed vagrant) if you did not, please check this link

$ vagrant up

After you get your prompt back, you can run this command to access the VM.

$ vagrant ssh

I have included a welcome message in your home dir, you can check it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions