Mini guide pour Vagrant

1.    Table des matières

  1. Table des matières
  2. Objectifs
  3. Installation Vagrant et VirtualBox

3.1. Qu’est ce que VirtualBox ?

3.2. Qu’est ce que Vagrant ?

3.3. Installation

3.4. Point d’attention

  1. Paramétrage de Vagrant

4.1. Installation d’extensions Vagrant utiles

4.1.1. Commande de contrôle des extensions

4.2. Installation de la box Vagrant Centos/7

4.3. Installation de la box Vagrant Ubuntu/Xenial64

  1. Configuration minimale d’une machine

5.1. Commande d’initialisation du fichier Vagrantfile

5.2. Vagrantfile: Fichier initial de configuration

  1. Commandes Vagrant basiques

6.1. Créer une machine Vagrant

6.2. Provisionner une machine Vagrant

6.3. Connaître la configuration SSH

6.4. Se connecter à une machine via SSH

6.5. Arrêter une machine Vagrant

6.6. Consulter l’état d’une machine Vagrant

6.7. Démarrer une machine Vagrant

6.8. Suspendre une machine Vagrant

6.9. Relancer une machine Vagrant

6.10. Réaliser un snapshot

6.11. Lister les snapshots disponibles

6.12. Détruire des données

6.13. Restaurer un snapshot

6.14. Créer une box à partir de votre machine Vagrant

6.15. Import une box Vagrant

6.16. Détruire une machine

  1. Références

7.1. Documentations officielles en anglais

7.2. Documentations officielles en français

7.3. Liens externes

2.    Objectifs

L’objectif de ces exercices est de préparer un serveur Linux pour recevoir l’installation d’une base de données MariaDB 10.2 à l’aide de VirtualBox et Vagrant.

Il existe plusieurs possibilités d’installer un serveur Linux Redhat ou Centos.

  • Machine physique(PC ou un Raspberry PI)
  • Machine virtuelle (VirtualBox, VmWare, Qemu, Virtual PC, LibVirt, …)
  • Espace compartimenté (SystemD, LXC, Docker, Rocket, …)
  • Machine dans le Cloud (AWS, OVH, Azure, Google, …)

3.    Installation Vagrant et VirtualBox

Nous allons installer un serveur Linux Centos 7. Pour cela, il nous faut deux logiciels installés:

3.1.    Qu’est ce que VirtualBox ?

VirtualBox est un programme permettant de faire fonctionner des machines virtuelles complètes depuis une machine physique.

  • La machine physique est appelée serveur Hôte.
  • Les machines virtuelles sont appelées machine Guest(Invité).

3.2.    Qu’est ce que Vagrant ?

Vagrant est un orchestrateur de création de machine virtuelle de manière automatique.

Vagrant est découpé en trois parties:

  • Settings: Configuration de machine virtuelle: Réseau, partage, ressources, …
  • Provider: Le type de plateforme virtuel cible: VirtualBox, Docker, HyperV, VmWare, …
  • Provisioning: Ensemble des opérations de post configuration de machine

3.3.    Installation

Pour installer Vagrant et VirtualBox, rendez-vous sur les sites respectifs des produits.

  • Sélectionner la dernière version stable
  • Sélectionner la version compatible avec votre serveur hôte
  • Télécharger les programmes en version binaire
  • Procéder à l’installation des produits

3.4.    Point d’attention

Pensez à ajouter le chemin vers le binaire vagrant sous Linux ou windows en configurant la variable $PATH ou %PATH% de votre système d’exploitation favori.

4.    Paramétrage de Vagrant

4.1.    Installation d’extensions Vagrant utiles

L’objectif est d’installer des extensions de gestion avancée des paramètres de la machine virtuelle.

Deux extensions très utiles pour Vagrant:

  • Configuration système de la machine virtuelle : vagrant-hostmanager

L’objectif est d’installer une extension de gestion avancée des configuration système et réseau de la machine virtuelle

Installation de l’extension hostmanager

  • Configuration d’un proxy HTTP pour accéder à Internet: vagrant-proxyconf

 

L’objectif est d’installer une extension de gestion avancée des proxy d’entreprise. Ces proxy permettent d’accéder à Internet sans connexion directe.

Installation de l’extension proxyconf

  • Vérification installation des plugins Vagrant

4.1.1.    Commande de contrôle des extensions

# vagrant plugin install vagrant-hostmanager

Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...

Installed the plugin 'vagrant-hostmanager (1.8.7)'!

# vagrant plugin install vagrant-proxyconf

Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...

Installed the plugin 'vagrant-proxyconf (1.5.2)'!

# vagrant plugin list

vagrant-hostmanager (1.8.7)

vagrant-proxyconf (1.5.2)

vagrant-share (1.1.9, system)

vagrant-vbguest (0.14.2)

4.2.    Installation de la box Vagrant Centos/7

Il est possible de chercher une image, appelée “box”, adaptée à votre besoin.

Le site de recherche d’images pour Vagrant se trouve ici:

https://app.vagrantup.com/boxes/search

L’objectif est de télécharger une image Centos 7 pour l’installation de la machine virtuelle.

# vagrant box list

centos/7 (virtualbox, 1611.01)

centos/7 (virtualbox, 1706.02)

centos/7 (virtualbox, 1707.01)

# vagrant box remove centos/7

You requested to remove the box 'centos/7' with provider

'virtualbox'. This box has multiple versions. You must

explicitly specify which version you want to remove with

the `--box-version` flag or specify the `--all` flag to remove all

versions. The available versions for this box are:

* 1611.01

* 1706.02

* 1707.01

# vagrant box remove --all centos/7

Box 'centos/7' (v1707.01) with provider 'virtualbox' appears

to still be in use by at least one Vagrant environment. Removing

the box could corrupt the environment. We recommend destroying

these environments first:

default (ID: 4a642badaf2f40f59ca673b81e57c431)

default (ID: d398483c131742f0b8adf4cd34dcd4c8)

Are you sure you want to remove this box? [y/N] y

Removing box 'centos/7' (v1707.01) with provider 'virtualbox'...

Removing box 'centos/7' (v1706.02) with provider 'virtualbox'...

Removing box 'centos/7' (v1611.01) with provider 'virtualbox'...

# vagrant box add centos/7

==> box: Loading metadata for box 'centos/7'

box: URL: https://vagrantcloud.com/centos/7

This box can work with multiple providers! The providers that it

can work with are listed below. Please review the list and choose

the provider you will be working with.

1) hyperv

2) libvirt

3) virtualbox

4) vmware_desktop

Enter your choice: 3

==> box: Adding box 'centos/7' (v1708.01) for provider: virtualbox

box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1708.01/providers/virtualbox.box

box: Progress: 100% (Rate: 11.2M/s, Estimated time remaining: --:--:--)

==> box: Successfully added box 'centos/7' (v1708.01) for 'virtualbox'!

4.3.    Installation de la box Vagrant Ubuntu/Xenial64

L’objectif est de télécharger une image Ubuntu/xenial64 pour l’installation de la machine virtuelle.

# vagrant box add ubuntu/xenial64

==> box: Loading metadata for box 'ubuntu/xenial64'

box: URL: https://vagrantcloud.com/ubuntu/xenial64

==> box: Adding box 'ubuntu/xenial64' (v20170922.0.0) for provider: virtualbox

box: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20170922.0.0/providers/virtualbox.box

box: Progress: 100% (Rate: 529k/s, Estimated time remaining: --:--:--)

==> box: Successfully added box 'ubuntu/xenial64' (v20170922.0.0) for 'virtualbox'!

# vagrant box list

centos/7        (virtualbox, 1708.01)

ubuntu/xenial64 (virtualbox, 20170922.0.0)

5.    Configuration minimale d’une machine

L’objectif est créer une configuration minimale permettant d’accéder de l’extérieur à la base de données MySQL/MariaDB.

5.1.    Commande d’initialisation du fichier Vagrantfile

#vagrant init

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.

5.2.    Vagrantfile: Fichier initial de configuration

# -*- 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://vagrantcloud.com/search.

#config.vm.box = "centos/7"

config.vm.box = "ubuntu/xenial64"

# 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

# Create a forwarded port mapping which allows access to a specific port

# within the machine from a port on the host machine. In the example below,

# accessing "localhost:8080" will access port 80 on the guest machine.

# NOTE: This will enable public access to the opened port

# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port

# within the machine from a port on the host machine and only allow access

# via 127.0.0.1 to disable public access

# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# 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"

# Create a public network, which generally matched to bridged network.

# Bridged networks make the machine appear as another physical device on

# your network.

# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is

# the path on the host to the actual folder. The second argument is

# the path on the guest to mount the folder. And the optional third

# argument is a set of non-required options.

# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various

# backing providers for Vagrant. These expose provider-specific options.

# Example for VirtualBox:

#

# config.vm.provider "virtualbox" do |vb|

#   # Display the VirtualBox GUI when booting the machine

#   vb.gui = true

#

#   # Customize the amount of memory on the VM:

#   vb.memory = "1024"

# end

#

# View the documentation for the provider you are using for more

# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as

# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the

# documentation for more information about their specific syntax and use.

# config.vm.provision "shell", inline: <<-SHELL

#   apt-get update

#   apt-get install -y apache2

# SHELL

end

6.    Commandes Vagrant basiques

6.1.    Créer une machine Vagrant

# vagrant up

Bringing machine 'default' up with 'virtualbox' provider...

==> default: Importing base box 'ubuntu/xenial64'...

==> default: Matching MAC address for NAT networking...

==> default: Checking if box 'ubuntu/xenial64' is up to date...

==> default: Setting the name of the VM: VagrantUbuntu_default_1506138297227_88972

==> default: Fixed port collision for 22 => 2222. Now on port 2200.

==> default: Clearing any previously set network interfaces...

==> default: Preparing network interfaces based on configuration...

default: Adapter 1: nat

==> default: Forwarding ports...

default: 22 (guest) => 2200 (host) (adapter 1)

==> default: Running 'pre-boot' VM customizations...

==> default: Booting VM...

==> default: Waiting for machine to boot. This may take a few minutes...

default: SSH address: 127.0.0.1:2200

default: SSH username: ubuntu

default: SSH auth method: password

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] GuestAdditions versions on your host (5.1.26) and guest (5.0.40) do not match.

Reading package lists...

Building dependency tree...

Reading state information...

Package 'virtualbox-guest-dkms' is not installed, so not removed

Package 'virtualbox-guest-x11' is not installed, so not removed

The following packages will be REMOVED:

virtualbox-guest-utils*

0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.

After this operation, 2,230 kB disk space will be freed.

(Reading database ... 53971 files and directories currently installed.)

Removing virtualbox-guest-utils (5.0.40-dfsg-0ubuntu1.16.04.1) ...

Purging configuration files for virtualbox-guest-utils (5.0.40-dfsg-0ubuntu1.16.04.1) ...

Processing triggers for man-db (2.7.5-1) ...

Reading package lists...

Building dependency tree...

Reading state information...

linux-headers-4.4.0-96-generic is already the newest version (4.4.0-96.119).

linux-headers-4.4.0-96-generic set to manually installed.

The following additional packages will be installed:

binutils cpp cpp-5 fakeroot gcc gcc-5 libasan2 libatomic1 libc-dev-bin

libc6-dev libcc1-0 libcilkrts5 libfakeroot libgcc-5-dev libgomp1 libisl15

libitm1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0

linux-libc-dev make manpages-dev

Suggested packages:

binutils-doc cpp-doc gcc-5-locales gcc-multilib autoconf automake libtool

flex bison gdb gcc-doc gcc-5-multilib gcc-5-doc libgcc1-dbg libgomp1-dbg

libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg

libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc

make-doc

The following NEW packages will be installed:

binutils cpp cpp-5 dkms fakeroot gcc gcc-5 libasan2 libatomic1 libc-dev-bin

libc6-dev libcc1-0 libcilkrts5 libfakeroot libgcc-5-dev libgomp1 libisl15

libitm1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0

linux-libc-dev make manpages-dev

0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.

Need to get 27.7 MB of archives.

After this operation, 101 MB of additional disk space will be used.

Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]

Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.4 [2,311 kB]

Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]

Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.4 [7,653 kB]

Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB]

Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.4 [38.8 kB]

Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.4 [55.0 kB]

Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.4 [27.4 kB]

Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.4 [8,912 B]

Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.4 [264 kB]

Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.4 [105 kB]

Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.4 [244 kB]

Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.4 [95.3 kB]

Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.4 [40.1 kB]

Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.4 [9,766 B]

Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.4 [131 kB]

Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.4 [2,237 kB

Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.4 [8,577 kB]

Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5,244 B]

Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]

Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 dkms all 2.2.0.3-2ubuntu11.3 [66.1 kB]

Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfakeroot amd64 1.20.2-1ubuntu1 [25.5 kB]

Get:23 http://archive.ubuntu.com/ubuntu xenial/main amd64 fakeroot amd64 1.20.2-1ubuntu1 [61.8 kB]

Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu9 [68.6 kB]

Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-96.119 [836 kB]

Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu9 [2,082 kB]

Get:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2,048 kB]

dpkg-preconfigure: unable to re-open stdin: No such file or directory

Fetched 27.7 MB in 1min 1s (449 kB/s)

Selecting previously unselected package libmpc3:amd64.

(Reading database ... 53959 files and directories currently installed.)

Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ...

Unpacking libmpc3:amd64 (1.0.3-1) ...

Selecting previously unselected package binutils.

Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.4_amd64.deb ...

Unpacking binutils (2.26.1-1ubuntu1~16.04.4) ...

Selecting previously unselected package libisl15:amd64.

Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ...

Unpacking libisl15:amd64 (0.16.1-1) ...

Selecting previously unselected package cpp-5.

Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package cpp.

Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ...

Unpacking cpp (4:5.3.1-1ubuntu1) ...

Selecting previously unselected package libcc1-0:amd64.

Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libgomp1:amd64.

Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libitm1:amd64.

Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libatomic1:amd64.

Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libasan2:amd64.

Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package liblsan0:amd64.

Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libtsan0:amd64.

Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libubsan0:amd64.

Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libcilkrts5:amd64.

Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libmpx0:amd64.

Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libquadmath0:amd64.

Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package libgcc-5-dev:amd64.

Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package gcc-5.

Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.4_amd64.deb ...

Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.4) ...

Selecting previously unselected package gcc.

Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ...

Unpacking gcc (4:5.3.1-1ubuntu1) ...

Selecting previously unselected package make.

Preparing to unpack .../archives/make_4.1-6_amd64.deb ...

Unpacking make (4.1-6) ...

Selecting previously unselected package dkms.

Preparing to unpack .../dkms_2.2.0.3-2ubuntu11.3_all.deb ...

Unpacking dkms (2.2.0.3-2ubuntu11.3) ...

Selecting previously unselected package libfakeroot:amd64.

Preparing to unpack .../libfakeroot_1.20.2-1ubuntu1_amd64.deb ...

Unpacking libfakeroot:amd64 (1.20.2-1ubuntu1) ...

Selecting previously unselected package fakeroot.

Preparing to unpack .../fakeroot_1.20.2-1ubuntu1_amd64.deb ...

Unpacking fakeroot (1.20.2-1ubuntu1) ...

Selecting previously unselected package libc-dev-bin.

Preparing to unpack .../libc-dev-bin_2.23-0ubuntu9_amd64.deb ...

Unpacking libc-dev-bin (2.23-0ubuntu9) ...

Selecting previously unselected package linux-libc-dev:amd64.

Preparing to unpack .../linux-libc-dev_4.4.0-96.119_amd64.deb ...

Unpacking linux-libc-dev:amd64 (4.4.0-96.119) ...

Selecting previously unselected package libc6-dev:amd64.

Preparing to unpack .../libc6-dev_2.23-0ubuntu9_amd64.deb ...

Unpacking libc6-dev:amd64 (2.23-0ubuntu9) ...

Selecting previously unselected package manpages-dev.

Preparing to unpack .../manpages-dev_4.04-2_all.deb ...

Unpacking manpages-dev (4.04-2) ...

Processing triggers for libc-bin (2.23-0ubuntu9) ...

Processing triggers for man-db (2.7.5-1) ...

Setting up libmpc3:amd64 (1.0.3-1) ...

Setting up binutils (2.26.1-1ubuntu1~16.04.4) ...

Setting up libisl15:amd64 (0.16.1-1) ...

Setting up cpp-5 (5.4.0-6ubuntu1~16.04.4) ...

Setting up cpp (4:5.3.1-1ubuntu1) ...

Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.4) ...

Setting up gcc-5 (5.4.0-6ubuntu1~16.04.4) ...

Setting up gcc (4:5.3.1-1ubuntu1) ...

Setting up make (4.1-6) ...

Setting up dkms (2.2.0.3-2ubuntu11.3) ...

Setting up libfakeroot:amd64 (1.20.2-1ubuntu1) ...

Setting up fakeroot (1.20.2-1ubuntu1) ...

update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode

Setting up libc-dev-bin (2.23-0ubuntu9) ...

Setting up linux-libc-dev:amd64 (4.4.0-96.119) ...

Setting up libc6-dev:amd64 (2.23-0ubuntu9) ...

Setting up manpages-dev (4.04-2) ...

Processing triggers for libc-bin (2.23-0ubuntu9) ...

Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso

mount: /dev/loop0 is write-protected, mounting read-only

Installing Virtualbox Guest Additions 5.1.26 - guest version is 5.0.40

Verifying archive integrity... All good.

Uncompressing VirtualBox 5.1.26 Guest Additions for Linux...........

VirtualBox Guest Additions installer

Copying additional installer modules ...

Installing additional modules ...

vboxadd.sh: Starting the VirtualBox Guest Additions.



Could not find the X.Org or XFree86 Window System, skipping.

Got different reports about installed GuestAdditions version:

Virtualbox on your host claims:   5.0.40

VBoxService inside the vm claims: 5.1.26

Going on, assuming VBoxService is correct...

Got different reports about installed GuestAdditions version:

Virtualbox on your host claims:   5.0.40

VBoxService inside the vm claims: 5.1.26

Going on, assuming VBoxService is correct...

==> default: Checking for guest additions in VM...

default: The guest additions on this VM do not match the installed version of

default: VirtualBox! In most cases this is fine, but in rare cases it can

default: prevent things such as shared folders from working properly. If you see

default: shared folder errors, please make sure the guest additions within the

default: virtual machine match the version of VirtualBox you have installed on

default: your host and reload your VM.

default:

default: Guest Additions Version: 5.0.40

default: VirtualBox Version: 5.1

==> default: Mounting shared folders...

default: /vagrant => //VagrantUbuntu

6.2.    Provisonner une machine Vagrant

# vagrant provision

6.3.    Connaître la configuration SSH

# vagrant ssh-config

Host default

HostName 127.0.0.1

User ubuntu

Port 2200

UserKnownHostsFile /dev/null

StrictHostKeyChecking no

PasswordAuthentication no

IdentityFile //VagrantUbuntu/.vagrant/machines/default/virtualbox/private_key

IdentitiesOnly yes

LogLevel FATAL

6.4.    Se connecter à une machine via SSH

# vagrant ssh

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

* Documentation:  https://help.ubuntu.com

* Management:     https://landscape.canonical.com

* Support:        https://ubuntu.com/advantage

Get cloud support with Ubuntu Advantage Cloud Guest:

http://www.ubuntu.com/business/services/cloud

0 packages can be updated.

0 updates are security updates.

ubuntu@ubuntu-xenial:~$ pwd

/home/ubuntu

ubuntu@ubuntu-xenial:~$ ls

ubuntu@ubuntu-xenial:~$ ls /etc

acpi                    cron.d          fuse.conf        insserv.conf     logrotate.conf  NetworkManager           protocols     security     terminfo

adduser.conf            cron.daily      gai.conf         insserv.conf.d   logrotate.d     networks                 python3       selinux      timezone

alternatives            cron.hourly     groff            iproute2         lsb-release     newt                     python3.5     services     tmpfiles.d

apm                     cron.monthly    group            iscsi            ltrace.conf     nsswitch.conf            rc0.d         sgml         ucf.conf

apparmor                crontab         group-           issue            lvm             opt                      rc1.d         shadow       udev

apparmor.d              cron.weekly     grub.d           issue.net        machine-id      os-release               rc2.d         shadow-      ufw

apport                  crypttab        gshadow          kbd              magic           overlayroot.conf         rc3.d         shells       updatedb.conf

apt                     dbus-1          gshadow-         kernel           magic.mime      overlayroot.local.conf   rc4.d         skel         update-manager

at.deny                 debconf.conf    gss              kernel-img.conf  mailcap         pam.conf                 rc5.d         sos.conf     update-motd.d

bash.bashrc             debian_version  hdparm.conf      ldap             mailcap.order   pam.d                    rc6.d         ssh          update-notifier

bash_completion         default         host.conf        ld.so.cache      manpath.config  passwd                   rc.local      ssl          vim

bash_completion.d       deluser.conf    hostname         ld.so.conf       mdadm           passwd-                  rcS.d         subgid       vmware-tools

bindresvport.blacklist  depmod.d        hosts            ld.so.conf.d     mime.types      perl                     resolvconf    subgid-      vtrgb

binfmt.d                dhcp            hosts.allow      legal            mke2fs.conf     pm                       resolv.conf   subuid       wgetrc

byobu                   dkms            hosts.deny       libaudit.conf    modprobe.d      polkit-1                 rmt           subuid-      X11

ca-certificates         dpkg            init             locale.alias     modules         pollinate                rpc           sudoers      xdg

ca-certificates.conf    ec2_version     init.d           locale.gen       modules-load.d  popularity-contest.conf  rsyslog.conf  sudoers.d    xml

calendar                environment     initramfs-tools  localtime        mtab            ppp                      rsyslog.d     sysctl.conf  zsh_command_not_found

cloud                   fonts           inputrc          logcheck         nanorc          profile                  screenrc      sysctl.d

console-setup           fstab           insserv          login.defs       network         profile.d                securetty     systemd

ubuntu@ubuntu-xenial:~$ sudo ifconfig

enp0s3    Link encap:Ethernet  HWaddr 02:a4:a0:f1:db:6e

inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

inet6 addr: fe80::a4:a0ff:fef1:db6e/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:74793 errors:0 dropped:0 overruns:0 frame:0

TX packets:20491 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:91532951 (91.5 MB)  TX bytes:1343884 (1.3 MB)

lo        Link encap:Local Loopback

inet addr:127.0.0.1  Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING  MTU:65536  Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1

RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ubuntu@ubuntu-xenial:~$ exit

logout

Connection to 127.0.0.1 closed.

 

6.5.    Arrêter une machine Vagrant

 

# vagrant halt

==> default: Attempting graceful shutdown of VM…

 

6.6.    Consulter l’état d’une machine Vagrant

# vagrant status

Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to

shut it down forcefully, or you can run `vagrant suspend` to simply

suspend the virtual machine. In either case, to restart it again,

simply run `vagrant up`.

# vagrant status

Current machine states:

default                   poweroff (virtualbox)

The VM is powered off. To restart the VM, simply run `vagrant up`

6.7.    Démarrer une machine Vagrant

# vagrant up

Bringing machine 'default' up with 'virtualbox' provider...

==> default: Checking if box 'ubuntu/xenial64' is up to date...

==> default: Clearing any previously set forwarded ports...

==> default: Fixed port collision for 22 => 2222. Now on port 2200.

==> default: Clearing any previously set network interfaces...

==> default: Preparing network interfaces based on configuration...

default: Adapter 1: nat

==> default: Forwarding ports...

default: 22 (guest) => 2200 (host) (adapter 1)

==> default: Running 'pre-boot' VM customizations...

==> default: Booting VM...

==> default: Waiting for machine to boot. This may take a few minutes...

default: SSH address: 127.0.0.1:2200

default: SSH username: ubuntu

default: SSH auth method: password

==> default: Machine booted and ready!

[default] GuestAdditions 5.1.26 running --- OK.

==> default: Checking for guest additions in VM...

==> default: Mounting shared folders...

default: /vagrant => //VagrantUbuntu

==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`

==> default: flag to force provisioning. Provisioners marked to run always will still run.

# vagrant status

Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to

shut it down forcefully, or you can run `vagrant suspend` to simply

suspend the virtual machine. In either case, to restart it again,

simply run `vagrant up`.

6.8.    Suspendre une machine Vagrant

# vagrant suspend

=> default: Saving VM state and suspending execution...

6.9.    Relancer une machine Vagrant

# vagrant resume

==> default: Resuming suspended VM...

==> default: Booting VM...

==> default: Waiting for machine to boot. This may take a few minutes...

default: SSH address: 127.0.0.1:2200

default: SSH username: ubuntu

default: SSH auth method: password

==> default: Machine booted and ready!

==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`

==> default: flag to force provisioning. Provisioners marked to run always will still run.

6.10.    Réaliser un snapshot

# vagrant snapshot help

Usage: vagrant snapshot <subcommand> [<args>]

Available subcommands:

delete

list

pop

push

restore

save

For help on any individual subcommand run `vagrant snapshot <subcommand> -h`

# vagrant snapshot save -h

Usage: vagrant snapshot save [options] [vm-name] <name>

Take a snapshot of the current state of the machine. The snapshot

can be restored via `vagrant snapshot restore` at any point in the

future to get back to this exact machine state.

Snapshots are useful for experimenting in a machine and being able

to rollback quickly.

-f, --force                      Replace snapshot without confirmation

-h, --help                       Print this help

# vagrant snapshot save -f init

==> default: Snapshotting the machine as 'init'...

==> default: Snapshot saved! You can restore the snapshot at any time by

==> default: using `vagrant snapshot restore`. You can delete it using

==> default: `vagrant snapshot delete`.

6.11.    Lister les snapshots disponibles

# vagrant snapshot list

init

6.12.    Détruire des données

# vagrant ssh

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

* Documentation:  https://help.ubuntu.com

* Management:     https://landscape.canonical.com

* Support:        https://ubuntu.com/advantage

Get cloud support with Ubuntu Advantage Cloud Guest:

http://www.ubuntu.com/business/services/cloud

0 packages can be updated.

0 updates are security updates.

Last login: Sat Sep 23 03:51:56 2017 from 10.0.2.2

ubuntu@ubuntu-xenial:~$ cat /etc/hosts

127.0.0.1       localhost

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost   ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

127.0.1.1       ubuntu-xenial   ubuntu-xenial

ubuntu@ubuntu-xenial:~$ sudo rm -f /etc/hosts

ubuntu@ubuntu-xenial:~$ cat /etc/hosts

cat: /etc/hosts: No such file or directory

ubuntu@ubuntu-xenial:~$ exit

logout

Connection to 127.0.0.1 closed.

6.13.    Restaurer un snapshot

# vagrant snapshot restore -h

Usage: vagrant snapshot restore [options] [vm-name] <name>

--[no-]provision             Enable or disable provisioning

--provision-with x,y,z       Enable only certain provisioners, by type or by name.

Restore a snapshot taken previously with snapshot save.

-h, --help                       Print this help

# vagrant snapshot restore init

==> default: Forcing shutdown of VM...

==> default: Restoring the snapshot 'init'...

==> default: Checking if box 'ubuntu/xenial64' is up to date...

==> default: Resuming suspended VM...

==> default: Booting VM...

==> default: Waiting for machine to boot. This may take a few minutes...

default: SSH address: 127.0.0.1:2200

default: SSH username: ubuntu

default: SSH auth method: password

==> default: Machine booted and ready!

# vagrant ssh

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

* Documentation:  https://help.ubuntu.com

* Management:     https://landscape.canonical.com

* Support:        https://ubuntu.com/advantage

Get cloud support with Ubuntu Advantage Cloud Guest:

http://www.ubuntu.com/business/services/cloud

0 packages can be updated.

0 updates are security updates.

Last login: Sat Sep 23 03:51:56 2017 from 10.0.2.2

ubuntu@ubuntu-xenial:~$ cat /etc/hosts

127.0.0.1       localhost

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost   ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

127.0.1.1       ubuntu-xenial   ubuntu-xenial

ubuntu@ubuntu-xenial:~$ logout

Connection to 127.0.0.1 closed.

6.14.    Créer une box à partir de votre machine Vagrant

# vagrant package -h

Usage: vagrant package [options] [name|id]

Options:

--base NAME                  Name of a VM in VirtualBox to package as a base box (VirtualBox Only)

--output NAME                Name of the file to output

--include FILE,FILE..        Comma separated additional files to package with the box

--vagrantfile FILE           Vagrantfile to package with the box

-h, --help                       Print this help

# vagrant package

init

# vagrant package

==> default: Attempting graceful shutdown of VM...

==> default: Clearing any previously set forwarded ports...

==> default: Exporting VM...

==> default: Compressing package to: //VagrantUbuntu/package.box

6.15.    Import une box Vagrant

# vagrant box add -f --name jmr package.box

==> box: Box file was not detected as metadata. Adding it directly...

==> box: Adding box 'jmr' (v0) for provider:

box: Unpacking necessary files from: file:////VagrantUbuntu/package.box

box: Progress: 100% (Rate: 18.8M/s, Estimated time remaining: --:--:--)

==> box: Successfully added box 'jmr' (v0) for 'virtualbox'!

6.16.    Détruire une machine

# vagrant destroy

default: Are you sure you want to destroy the 'default' VM? [y/N] y

==> default: Destroying VM and associated drives...

7.    Références

7.1.    Documentations officielles en anglais

 

7.2.    Documentations officielles en français

7.3.    Liens externes

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *