Outils pour utilisateurs

Outils du site


devweb:vagrant (lu 25279 fois)

Vagrant

Apparemment c’est le truc qui va bien pour installer une VM pour faire du dev sans pourrir sa machine.

Installation

Installer virtualbox

sudo apt-get install virtualbox virtualbox-dkms virtualbox-qt

Ne pas installer le vagrant disponible dans les paquets car la version est obsolète. Par exemple, la version 1.4 dispo ne supporte pas virtualbox 5 contrairement à la version dispo sur le site de vagrant qui est en 1.8

https://www.vagrantup.com/downloads.html

Créer sa première machine

J’ai cherché un peu sur la catalogue https://atlas.hashicorp.com et j’ai chercher une debian avec apache php mysql.

J’ai trouvé celle ci ⇒ https://atlas.hashicorp.com/tjo/boxes/debian-jessie64-lamp-stack

On crée un répertoire de travail

mkdir /home/user/dev/mon_projet
cd /home/user/dev/mon_projet

et on tape la commande fournit

$ vagrant init tjo/debian-jessie64-lamp-stack; vagrant up --provider virtualbox

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'tjo/debian-jessie64-lamp-stack'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'tjo/debian-jessie64-lamp-stack' is up to date...
==> default: Setting the name of the VM: QAint_default_1469718758382_40918
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/user/dev/mon_projet

Nous voici avec une VM de debian jessie avec de apache, mysql et php d’installé.

Pour se logguer simplement en ssh, tapez la commande

vagrant ssh

Pour arrêter la machine, tapez la commande

vagrant halt

Modifiez le fichier Vagrantfile et configurer une adresse ip pour votre machine

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.10"

Scotch Box

Scotch Box fourni une box vagrant toute prête sans besoin de puppet ou cook chef

devweb/vagrant.txt · Dernière modification: 19-09-2016 21:46 de edmc73