VAGRANT
Usage: vagrant [options] <command> [<args>] -v, --version Print the version and exit. -h, --help Print this help. Common commands: box manages boxes: installation, removal, etc. destroy stops and deletes all traces of the vagrant machine global-status outputs status Vagrant environments for this user halt stops the vagrant machine help shows the help for a subcommand init initializes a new Vagrant environment by creating a Vagrantfile login log in to HashiCorp's Vagrant Cloud package packages a running vagrant environment into a box plugin manages plugins: install, uninstall, update, etc. port displays information about guest port mappings powershell connects to machine via powershell remoting provision provisions the vagrant machine push deploys code in this environment to a configured destination rdp connects to machine via RDP reload restarts vagrant machine, loads new Vagrantfile configuration resume resume a suspended vagrant machine snapshot manages snapshots: saving, restoring, etc. ssh connects to machine via SSH ssh-config outputs OpenSSH valid configuration to connect to the machine status outputs status of the vagrant machine suspend suspends the machine up starts and provisions the vagrant environment validate validates the Vagrantfile version prints current and latest Vagrant version For help on any individual command run `vagrant COMMAND -h` Additional subcommands are available, but are either more advanced or not commonly used. To see all subcommands, run the command `vagrant list-commands`.
VAGRANT BOX
Usage: vagrant box <subcommand> [<args>] Available subcommands: add list outdated prune remove repackage update For help on any individual subcommand run `vagrant box <subcommand> -h`
VAGRANT BOX ADD
Usage: vagrant box add [options] <name, url, or path> Options: -c, --clean Clean any temporary download files -f, --force Overwrite an existing box if it exists --insecure Do not validate SSL certificates --cacert FILE CA certificate for SSL download --capath DIR CA certificate directory for SSL download --cert FILE A client SSL cert, if needed --location-trusted Trust 'Location' header from HTTP redirects and use the same credentials for subsequent urls as for the initial one --provider PROVIDER Provider the box should satisfy --box-version VERSION Constrain version of the added box The box descriptor can be the name of a box on HashiCorp's Vagrant Cloud, or a URL, or a local .box file, or a local .json file containing the catalog metadata. The options below only apply if you're adding a box file directly, and not using a Vagrant server or a box structured like 'user/box': --checksum CHECKSUM Checksum for the box --checksum-type TYPE Checksum type (md5, sha1, sha256) --name BOX Name of the box -h, --help Print this help
Télécharger en local une box depuis le Vagrant Cloud
vagrant box add [options] <name>
ex :
$ vagrant box add debian/stretch64 --provider virtualbox ==> box: Loading metadata for box 'debian/stretch64' box: URL: https://vagrantcloud.com/debian/stretch64 ==> box: Adding box 'debian/stretch64' (v9.5.0) for provider: virtualbox box: Downloading: https://vagrantcloud.com/debian/boxes/stretch64/versions/9.5.0/providers/virtualbox.box box: ==> box: Successfully added box 'debian/stretch64' (v9.5.0) for 'virtualbox'! $ vagrant box list debian/stretch64 (virtualbox, 9.5.0)
$ vagrant box add debian/stretch64 --box-version 9.1 --provider virtualbox ==> box: Loading metadata for box 'debian/stretch64' box: URL: https://vagrantcloud.com/debian/stretch64 ==> box: Adding box 'debian/stretch64' (v9.1.0) for provider: virtualbox box: Downloading: https://vagrantcloud.com/debian/boxes/stretch64/versions/9.1.0/providers/virtualbox.box box: ==> box: Successfully added box 'debian/stretch64' (v9.1.0) for 'virtualbox'! $ vagrant box list debian/stretch64 (virtualbox, 9.1.0)
Télécharger en local une box depuis une url
vagrant box add [options] <url>
ex :
$ vagrant box add https://atlas.hashicorp.com/envimation/boxes/ubuntu-xenial-docker ==> box: Loading metadata for box 'https://atlas.hashicorp.com/envimation/boxes/ubuntu-xenial-docker' ==> box: Adding box 'envimation/ubuntu-xenial-docker' (v1.0.0-1516241473) for provider: virtualbox box: Downloading: https://vagrantcloud.com/envimation/boxes/ubuntu-xenial-docker/versions/1.0.0-1516241473/providers/virtualbox.box box: ==> box: Successfully added box 'envimation/ubuntu-xenial-docker' (v1.0.0-1516241473) for 'virtualbox'! $ vagrant box list envimation/ubuntu-xenial-docker (virtualbox, 1.0.0-1516241473)
Ajouter une box depuis un fichier .box local
vagrant box add [options] <path>
Le fichier .box utilisé pour la création de la box a été généré avec la commande vagrant package.
ex :
$ vagrant box add custom-lamp.box --name custom-lamp ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'custom-lamp' (v0) for provider: box: Unpacking necessary files from: file://D:/vagrant/projects/demo/custom-lamp.box box: ==> box: Successfully added box 'custom-lamp' (v0) for 'virtualbox'! $ vagrant box list custom-lamp (virtualbox, 0)
VAGRANT BOX OUTDATED
Usage: vagrant box outdated [options] Checks if there is a new version available for the box that are you are using. If you pass in the --global flag, all boxes will be checked for updates. Options: --global Check all boxes installed --insecure Do not validate SSL certificates --cacert FILE CA certificate for SSL download --capath DIR CA certificate directory for SSL download --cert FILE A client SSL cert, if needed -h, --help Print this help
Vérifier si la box de l’environnement en cours est à jour
vagrant box outdated [options]
ex :
$ vagrant box outdated
Checking if box 'primalskill/ubuntu-trusty64' is up to date...
Vérifier si l’ensemble des boxes sont à jour
vagrant box outdated [options] --global
ex :
$ vagrant box outdated --global
* 'primalskill/ubuntu-trusty64' for 'virtualbox' (v1.0.0) is up to date
* 'hashicorp/precise64' for 'virtualbox' (v1.1.0) is up to date
* 'emessiha/ubuntu64-java' for 'virtualbox' (v1.0.0) is up to date
* 'debian/stretch64' for 'virtualbox' is outdated! Current: 9.1.0. Latest: 9.5.0
* 'AlbanMontaigu/boot2docker' for 'virtualbox' is outdated! Current: 18.06.0-ce. Latest: 18.06.1.pre.ce
VAGRANT BOX PRUNE
Usage: vagrant box prune [options] Options: -p, --provider PROVIDER The specific provider type for the boxes to destroy. -n, --dry-run Only print the boxes that would be removed. --name NAME The specific box name to check for outdated versions. -f, --force Destroy without confirmation even when box is in use. -h, --help Print this help
Supprimer toutes les boxes dont une version plus récente existe en local
vagrant box prune [options]
ex :
$ vagrant box prune
The following boxes will be kept...
AlbanMontaigu/boot2docker (virtualbox, 18.06.0-ce)
debian/stretch64 (virtualbox, 9.5.0)
emessiha/ubuntu64-java (virtualbox, 1.0.0)
hashicorp/precise64 (virtualbox, 1.1.0)
primalskill/ubuntu-trusty64 (virtualbox, 1.0.0)
Checking for older boxes...
Removing box 'debian/stretch64' (v9.1.0) with provider 'virtualbox'...
Removing box 'debian/stretch64' (v9.2.0) with provider 'virtualbox'....
Mode simulation
vagrant box prune [options] --dry-run
ex :
$ vagrant box prune --dry-run
The following boxes will be kept...
AlbanMontaigu/boot2docker (virtualbox, 18.06.0-ce)
debian/stretch64 (virtualbox, 9.5.0)
emessiha/ubuntu64-java (virtualbox, 1.0.0)
hashicorp/precise64 (virtualbox, 1.1.0)
primalskill/ubuntu-trusty64 (virtualbox, 1.0.0)
Checking for older boxes...
Would remove debian/stretch64 virtualbox 9.1.0
Would remove debian/stretch64 virtualbox 9.2.0
VAGRANT BOX REMOVE
Usage: vagrant box remove <name> Options: -f, --force Remove without confirmation. --provider PROVIDER The specific provider type for the box to remove --box-version VERSION The specific version of the box to remove --all Remove all available versions of the box -h, --help Print this help
Supprimer une box téléchargée en local
vagrant box remove <name>
ex :
$ vagrant box list debian/stretch64 (virtualbox, 9.1.0) debian/stretch64 (virtualbox, 9.5.0) $ vagrant box remove debian/stretch64 You requested to remove the box 'debian/stretch64' 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: * 9.1.0 * 9.5.0 $ vagrant box remove debian/stretch64 --box-version 9.1.0 Removing box 'debian/stretch64' (v9.1.0) with provider 'virtualbox'... $ vagrant box list debian/stretch64 (virtualbox, 9.5.0)
Supprimer toutes les versions d’une box spécifique téléchargée en local
vagrant box remove <name> --all
ex :
$ vagrant box remove debian/stretch64 --all
Removing box 'debian/stretch64' (v9.5.0) with provider 'virtualbox'...
Removing box 'debian/stretch64' (v9.1.0) with provider 'virtualbox'...
Supprimer toutes les boxes téléchargées en local
vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f
ex :
$ vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f Removing box 'AlbanMontaigu/boot2docker' (v18.06.0-ce) with provider 'virtualbox'... Removing box 'debian-9.5' (v0) with provider 'virtualbox'... Removing box 'debian/stretch64' (v0) with provider 'virtualbox'... Removing box 'debian/stretch64:9.5' (v0) with provider 'virtualbox'... Removing box 'emessiha/ubuntu64-java' (v1.0.0) with provider 'virtualbox'... Removing box 'hashicorp/precise64' (v1.1.0) with provider 'virtualbox'... Removing box 'primalskill/ubuntu-trusty64' (v1.0.0) with provider 'virtualbox'... $ vagrant box list There are no installed boxes! Use `vagrant box add` to add some.
VAGRANT BOX UPDATE
Usage: vagrant box update [options] Updates the box that is in use in the current Vagrant environment, if there any updates available. This does not destroy/recreate the machine, so you'll have to do that to see changes. To update a specific box (not tied to a Vagrant environment), use the --box flag. Options: --box BOX Update a specific box --provider PROVIDER Update box with specific provider -f, --force Overwrite an existing box if it exists --insecure Do not validate SSL certificates --cacert FILE CA certificate for SSL download --capath DIR CA certificate directory for SSL download --cert FILE A client SSL cert, if needed -h, --help Print this help
Mettre à jour la box de l’environnement en cours
vagrant box update [options]
Mettre à jour une box spécifique
vagrant box update [options] --box <name>
ex :
$ vagrant box list debian/stretch64 (virtualbox, 9.1.0) debian/stretch64 (virtualbox, 9.2.0) $ vagrant box outdated --global * 'debian/stretch64' for 'virtualbox' is outdated! Current: 9.1.0. Latest: 9.5.0 * 'debian/stretch64' for 'virtualbox' is outdated! Current: 9.2.0. Latest: 9.5.0 $ vagrant box update --box debian/stretch64 Checking for updates to 'debian/stretch64' Latest installed version: 9.2.0 Version constraints: > 9.2.0 Provider: virtualbox Updating 'debian/stretch64' with provider 'virtualbox' from version '9.2.0' to '9.5.0'... Loading metadata for box 'https://vagrantcloud.com/debian/stretch64' Adding box 'debian/stretch64' (v9.5.0) for provider: virtualbox Downloading: https://vagrantcloud.com/debian/boxes/stretch64/versions/9.5.0/providers/virtualbox.box Successfully added box 'debian/stretch64' (v9.5.0) for 'virtualbox'! $ vagrant box list debian/stretch64 (virtualbox, 9.1.0) debian/stretch64 (virtualbox, 9.2.0) debian/stretch64 (virtualbox, 9.5.0)
VAGRANT DESTROY
Usage: vagrant destroy [options] [name|id] Options: -f, --force Destroy without confirmation. --[no-]parallel Enable or disable parallelism if provider supports it (automatically enables force) -h, --help Print this help
Arrêter et supprimer la machine Vagrant
vagrant destroy [options] [name|id]
ex :
$ vagrant destroy default: Are you sure you want to destroy the 'default' VM? [y/N] y ==> default: Forcing shutdown of VM... ==> default: Destroying VM and associated drives... $ vagrant status Current machine states: default not created (virtualbox) The environment has not yet been created. Run `vagrant up` to create the environment. If a machine is not created, only the default provider will be shown. So if a provider is not listed, then the machine is not created for that environment.
VAGRANT HALT
Usage: vagrant halt [options] [name|id] Options: -f, --force Force shut down (equivalent of pulling power) -h, --help Print this help
Arrêter la machine Vagrant
vagrant halt [options] [name|id]
ex :
$ vagrant halt ==> default: Attempting graceful shutdown of VM... $ vagrant status Current machine states: default poweroff (virtualbox) The VM is powered off. To restart the VM, simply run `vagrant up`
VAGRANT INIT
Usage: vagrant init [options] [name [url]] Options: --box-version VERSION Version of the box to add -f, --force Overwrite existing Vagrantfile -m, --minimal Use minimal Vagrantfile template (no help comments). Ignored with --template --output FILE Output path for the box. '-' for stdout --template FILE Path to custom Vagrantfile template -h, --help Print this help
Initialiser un nouvel environnement Vagrant en créant un fichier Vagrantfile
vagrant init <name> [url]
ex :
$ vagrant init hashicorp/precise64
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.
Cette commande a généré le fichier Vagrantfile écrit en Ruby suivant dans le répertoire courant :
# -*- 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 = "hashicorp/precise64" # 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
Ce qui donne, sans les commentaires ni les lignes vides :
$ grep -v -E "^[[:space:]]*(#|/|$|;)" Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
end
VAGRANT PACKAGE
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
Générer une image taguée à partir de la VM courante
vagrant package [options] --output boxname.box
ex :
$ vagrant package --output custom-lamp.box
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Exporting VM...
==> default: Compressing package to: D:/vagrant/projects/demo/custom-lamp.box
Générer une image taguée à partir d’une VM VirtualBox
vagrant package [options] --base VBdisplayname --output boxname.box
ex :
$ vagrant package --base centos7-minimal --output Centos7-server.box
==> centos7-minimal: Attempting graceful shutdown of VM...
==> centos7-minimal: Clearing any previously set forwarded ports...
==> centos7-minimal: Exporting VM...
==> centos7-minimal: Compressing package to: D:/vagrant/projects/vagrant-box/Centos7-server.box
VAGRANT PLUGIN
Usage: vagrant plugin <command> [<args>] Available subcommands: expunge install license list repair uninstall update For help on any individual command run `vagrant plugin COMMAND -h`
VAGRANT PLUGIN INSTALL
Usage: vagrant plugin install <name>... [-h] --entry-point NAME The name of the entry point file for loading the plugin. --plugin-clean-sources Remove all plugin sources defined so far (including defaults) --plugin-source PLUGIN_SOURCE Add a RubyGems repository source --plugin-version PLUGIN_VERSION Install a specific version of the plugin --verbose Enable verbose output for plugin installation -h, --help Print this help
Installer un plugin
vagrant plugin install <name> [<name>...]
Liste des plugins disponibles
GitHub – hashicorp/vagrant – Available Vagrant Plugins
ex :
$ vagrant plugin list No plugins installed. $ vagrant plugin install vagrant-vbguest Installing the 'vagrant-vbguest' plugin. This can take a few minutes... Installed the plugin 'vagrant-vbguest (0.16.0)'! $ vagrant plugin list vagrant-vbguest (0.16.0)
$ vagrant plugin install vagrant-vbguest --plugin-version 0.13 Installing the 'vagrant-vbguest --version '0.13'' plugin. This can take a few minutes... Installed the plugin 'vagrant-vbguest (0.13.0)'! $ vagrant plugin list vagrant-vbguest (0.13.0) - Version Constraint: 0.13
VAGRANT PLUGIN LIST
Usage: vagrant plugin list [-h] -h, --help Print this help
Afficher la liste des plugins installés
vagrant plugin list
ex :
$ vagrant plugin list
vagrant-vbguest (0.16.0)
VAGRANT PLUGIN UNINSTALL
Usage: vagrant plugin uninstall <name> [<name>...] [-h] -h, --help Print this help
Désinstaller un plugin
vagrant plugin uninstall <name> [<name> ...]
ex :
$ vagrant plugin list vagrant-timezone (1.2.0) vagrant-vbguest (0.16.0) - Version Constraint: > 0 $ vagrant plugin uninstall vagrant-vbguest Uninstalling the 'vagrant-vbguest' plugin... Successfully uninstalled micromachine-2.0.0 Successfully uninstalled vagrant-vbguest-0.16.0 $ vagrant plugin list vagrant-timezone (1.2.0)
VAGRANT PLUGIN UPDATE
Usage: vagrant plugin update [names...] [-h] -h, --help Print this help
Mettre à jour un plugin installé
vagrant plugin update [names...]
ex :
$ vagrant plugin list vagrant-vbguest (0.13.0) - Version Constraint: 0.13 $ vagrant plugin update vagrant-vbguest Updating plugins: vagrant-vbguest. This may take a few minutes... Successfully uninstalled vagrant-vbguest-0.13.0 Updated 'vagrant-vbguest' to version '0.16.0'! $ vagrant plugin list vagrant-vbguest (0.16.0) - Version Constraint: > 0
VAGRANT PROVISION
Usage: vagrant provision [vm-name] [--provision-with x,y,z] --provision-with x,y,z Enable only certain provisioners, by type or by name. -h, --help Print this help
Provisionner une machine Vagrant
vagrant provision [vm-name] [--provision-with x,y,z]
ex :
$ vagrant provision
==> default: Running provisioner: file...
VAGRANT RELOAD
Usage: vagrant reload [vm-name] --[no-]provision Enable or disable provisioning --provision-with x,y,z Enable only certain provisioners, by type or by name. -h, --help Print this help
Redémarrer la machine Vagrant en chargeant les modifications du fichier Vagrantfile
vagrant reload [vm-name]
La machine virtuelle sera redémarrée mais pas reprovisionnée.
Les modifications du ficher Vagrantfile seront rechargées pour être prises en compte.
Equivaut à :
vagrant halt
puis vagrant up
vagrant reload --provision [vm-name]
La machine virtuelle sera redémarrée et reprovisionnée à partir du fichier Vagrantfile.
Les modifications du ficher Vagrantfile seront rechargées pour être prises en compte.
Equivaut à :
vagrant halt
puis vagrant up --provision
ex :
$ vagrant ssh Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64) * Documentation: https://help.ubuntu.com/ New release '14.04.5 LTS' available. Run 'do-release-upgrade' to upgrade to it. Welcome to your Vagrant-built virtual machine. Last login: Fri Sep 14 06:23:18 2012 from 10.0.2.2 vagrant@precise64:~$
VAGRANT SSH
Usage: vagrant ssh [options] [name|id] [-- extra ssh args] Options: -c, --command COMMAND Execute an SSH command directly -p, --plain Plain mode, leaves authentication up to user -t, --[no-]tty Enables tty when executing an ssh command (defaults to true) -h, --help Print this help
Se connecter à une machine Vagrant via SSH
vagrant ssh [options] [name|id] [-- extra ssh args]
Le fichier Vagrantfile est situé dans le répertoire courant.
ex :
$ vagrant ssh Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64) * Documentation: https://help.ubuntu.com/ New release '14.04.5 LTS' available. Run 'do-release-upgrade' to upgrade to it. Welcome to your Vagrant-built virtual machine. Last login: Fri Sep 14 06:23:18 2012 from 10.0.2.2 vagrant@precise64:~$
Exécuter une commande sur la machine Vagrant et quitter
vagrant ssh -c "<command>"
ex :
$ vagrant ssh -c "sudo yum update -y"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.clouvider.net
* extras: mirror.clustered.net
* updates: mirror.clustered.net
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package acl.x86_64 0:2.2.49-6.el6 will be updated
---> Package acl.x86_64 0:2.2.49-7.el6_9.1 will be an update
[...]
VAGRANT STATUS
Usage: vagrant status [name|id] -h, --help Print this help
Afficher l’état d’une machine Vagrant
vagrant status [name|id]
ex :
$ vagrant status Current machine states: default saved (virtualbox) To resume this VM, simply run `vagrant up`. $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'hashicorp/precise64' 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:2222 default: SSH username: vagrant default: SSH auth method: private key ==> 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. $ 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 SUSPEND
Usage: vagrant suspend [name|id] -h, --help Print this help
Sauvegarder l’état d’une machine Vagrant
vagrant suspend [name|id]
ex :
$ vagrant suspend ==> default: Saving VM state and suspending execution... $ vagrant status Current machine states: default saved (virtualbox) To resume this VM, simply run `vagrant up`.
VAGRANT UP
Usage: vagrant up [options] [name|id] Options: --[no-]provision Enable or disable provisioning --provision-with x,y,z Enable only certain provisioners, by type or by name. --[no-]destroy-on-error Destroy machine if any fatal error happens (default to true) --[no-]parallel Enable or disable parallelism if provider supports it --provider PROVIDER Back the machine with a specific provider --[no-]install-provider If possible, install the provider if it isn't installed -h, --help Print this help
Démarrer et provisionner l’environnement Vagrant
vagrant up [options] [name|id]
ex :
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hashicorp/precise64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'hashicorp/precise64'
default: URL: https://vagrantcloud.com/hashicorp/precise64
==> default: Adding box 'hashicorp/precise64' (v1.1.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/hashicorp/boxes/precise64/versions/1.1.0/providers/virtualbox.box
default:
==> default: Successfully added box 'hashicorp/precise64' (v1.1.0) for 'virtualbox'!
==> default: Importing base box 'hashicorp/precise64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Setting the name of the VM: demo_default_1540827750667_27656
==> 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: 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: 4.2.0
default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
default: /vagrant => D:/vagrant/projects/demo
Reprendre une environnement Vagrant suspendu
vagrant up [options] [name|id]
ex :
$ vagrant status Current machine states: default saved (virtualbox) To resume this VM, simply run `vagrant up`. $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'hashicorp/precise64' 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:2222 default: SSH username: vagrant default: SSH auth method: private key ==> 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. $ 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 VALIDATE
Usage: vagrant validate -h, --help Print this help
Vérifier la syntaxe d’un fichier Vagrantfile
vagrant validate
ex :
$ vagrant validate There is a syntax error in the following Vagrantfile. The syntax error message is reproduced below for convenience: D:/vagrant/projects/demo/Vagrantfile:24: syntax error, unexpected tIDENTIFIER, expecting keyword_end # accessing "localhost:8080" will access port 80 on ^ $ echo $? 1