Outils pour utilisateurs

Outils du site


devweb:vagrant (lu 25385 fois)

Ceci est une ancienne révision du document !


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

Mais finalement, j’ai eu un problème avec le support VT-x et j’ai du installer une version 32bit de debian, celle-ci

https://pety.dynu.net/cloudbank_repo/debian_jessie_32bit.box

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 mon_projet ~/Téléchargements/debian_jessie_32bit.box 
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.



$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'mon_projet' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'mon_projet' (v0) for provider: virtualbox
    default: Unpacking necessary files from: file:///home/user/T%C3%A9l%C3%A9chargements/debian_jessie_32bit.box
==> default: Successfully added box 'mon_projet' (v0) for 'virtualbox'!
==> default: Importing base box 'mon_projet'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: mon_projet_default_1469714598425_85852
==> 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: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH 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 toute fraiche. Pour se logguer simplement en ssh, tapez la commande

vagrant ssh

Pour arrêter la machine, tapez la commande

vagrant halt
devweb/vagrant.1469718672.txt.gz · Dernière modification: 28-07-2016 17:11 de edmc73