Thursday, October 27, 2016

Vagrant Installation, Configuration, Running

The first step in configuring any Vagrant project is to create a Vagrantfile. The purpose of the Vagrantfile is twofold:
  1. Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.
  2. Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.
$ mkdir vagrant_getting_started
$ cd vagrant_getting_started
$ vagrant init
run vagrant init in a pre-existing directory to set up Vagrant for an existing project.

Converting vm box to varagan base box

$ sudo apt-get install linux-headers-$(uname -r) build-essential dkms

pack

$ vagrant package --base my-virtual-machine


Package the existing VirtualBox VM (VDI format)

First we need to create ubuntu16.04.vdi file in virtualbox
secondly –base name equal to vms name of virtual machine ( vboxmanage list vms)



vagrant package --base ubuntu16.04 --output /media/data-6/edx-platform/ubuntu16.04.box





























Add the box to vagrant

vagrant box add ubuntu16.04 ./box/ubuntu16.04.box









$ vagrant init ubuntu16.04






$ vagrant up
configuration (vagrantfile)


config.vm.provider "virtualbox" do |vb|
                vb.memory = 1024
                vb.customize [
                        "modifyvm", :id,
                        "--cpus", 4,
                        "--pae", "on",
                ]
        End

Vagrant.configure(2) do |config|

# Creates an edX fullstack VM from an official release
config.vm.box = openedx_releases[rel][:name]
config.vm.box_url = "http://files.edx.org/vagrant-images/#{openedx_releases[rel][:file]}"

config.vm.synced_folder ".", "/vagrant", disabled: true
config.ssh.insert_key = true

config.vm.network :private_network, ip: "192.168.33.10"
config.hostsupdater.aliases = ["preview.localhost"]

config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 4096]
vb.customize ["modifyvm", :id, "--cpus", 2]

# Allow DNS to work for Ubuntu 12.10 host
# http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

  end

1 comment: