vagrant workshop 2015

Post on 17-Jul-2015

204 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Workshop

CLLFST

Wait What's That?

● A vagrant is someone who moves a lot from place to place because he has no permanent home or job, and have to ask for or steal things in order to live.

● Vagrant is a package manager for an entire development environment(VMs basically)

Why Do I Need Vagrant?

● Say goodbye to my machine excuse.● Identical development environment for

everyone in the team● Sharing apps and scripts is a lot more easier

Hmm Interesting!! Pre-installed on Linux?

● No! cause it's EASY :D● Go to http://www.vagrantup.com/downloads● Download the proper package for your operating

system and architecture.● You can choose the version (latest or old ones)

Linux(Debian/Ubuntu) Case?

● Go to the directory where you downloaded the package. Eg: cd /home/haifa/Downloads

● Depending on the package type:– Deb package:

dpkg -i vagrant_version_architecture.deb

– RPM package convert it to .deb using alien

or

– rpm -ivh vagrant_version_architecture.rpm installez rpm (sudo apt-get install rpm)

How can I set up my environment?● You should make the difference between:

– A Provider: software responsible for creating and managing the virtual machines used by Vagrant. Eg: vmware or virtualbox in our case.

– A Provisioner: software/developer doing some tasks using the vm instance already provided: set up the virtual server, install all necessary software and execute different tasks. The most used provisioners are: Puppet, Chef.. or via Shell Script.

Clear. That's all?

● Two more words you should know:– A box: a package containing a representation of a

virtual machine running a specific operating system, for a specific Provider.(base image to quickly clone a virtual machine)

– Vagrantfile: a file in which the vagrant configuration is based.

It shall be placed in your repository root. In this file you will define which base box you want.

Vagrantfile ?● The primary function of the Vagrantfile is to

describe the type of machine required for a project, and how to configure and provision these machines.

● Vagrant is meant to run with one Vagrantfile per project, which allows other developers involved in the project to check out the code, run vagrant up, and be on their way. Vagrantfiles are portable across every platform Vagrant supports.

Okay! Let me make a Vagrantfile..

● Let's read it together:●

This will place a Vagrantfile in your current directory. Let's take a look at the Vagrantfile. Don't be afraid if it looks intimidating, it is filled with comments and examples.

# -*- mode: ruby -*-

# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure

# configures the configuration version (we support older styles for

# backwards compatibility). Please don't change it unless you know what

# you're doing.

Vagrant.configure(2) do |config|

# The most common configuration options are documented and commented below.

# For a complete reference, please see the online documentation at

# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for

# boxes at https://atlas.hashicorp.com/search.

config.vm.box = "base"

# Disable automatic box update checking. If you disable this, then

# boxes will only be checked for updates when the user runs

# `vagrant box outdated`. This is not recommended.

# config.vm.box_check_update = false

don't change it unless you know what you're doing haha

● The Vagrantfile is a very flexible configuration format. Since it is just Ruby, there is a lot you can do with it. However, in that same vein, since it is Ruby, there are a lot of ways you can shoot yourself in the foot.

● The syntax of Vagrantfiles is Ruby, but knowledge of the Ruby programming language is not necessary to make modifications to the Vagrantfile, since it is mostly simple variable assignment.

Available Configuration Options

● Minimum Vagrant Version:Vagrant.require_version ">= 1.3.5"

● config.vm.hostname● config.vm.network● config.vm.post_up_message

… you can check https://docs.vagrantup.com/v2/vagrantfile/ for more configuration tricks .

Accessing my VM?

● Vagrant allows you to access via ssh to your VM (that's the default method)

● The settings within config.ssh relate to configuring how Vagrant will access your machine over SSH. As with most Vagrant settings, the defaults are typically fine, but you can fine tune whatever you'd like.

● config.ssh.username● config.ssh.password● config.ssh.port and so on

Useful commands?

● Vagrant box add● Vagrant box list

● Vagrant init ● Vagrant up

● Vagrant status● Vagrant ssh

● Exit● Vagrant halt

Sharing it with the team?

● Vagrant Share requires an account with HashiCorp's Atlas to be used.

● Vagrant connect● vagrant share

Downloading boxes

● Go to https://vagrantcloud.com/ and choose one of hundreds of linux boxes :)

Hope it was great as a start!

● Stop everything and vagrant up :D

Haifa Ftirich CLLFST

top related