Vagrant
De Linuxmemo.
(Différences entre les versions)
(→Liste de VM et status) |
(→Plugins) |
||
Ligne 73 : | Ligne 73 : | ||
vagrant status vmname | vagrant status vmname | ||
==Plugins== | ==Plugins== | ||
+ | vagrant plugin list | ||
+ | vagrant plugin install <name>... | ||
+ | vagrant plugin update | ||
+ | vagrant plugin update [<name>] | ||
+ | vagrant plugin license <name> <license-file> | ||
+ | vagrant plugin uninstall <name> [<name2> <name3> ...] |
Version du 19 avril 2016 à 21:30
Sommaire |
Install
https://www.vagrantup.com/downloads.html
Nouveau projet (vide)
mkdir vagrant_getting_started cd vagrant_getting_started vagrant init vim Vagrantfile
Les "Boxes"
- ajouter une box
vagrant box add hashicorp/precise64 (vagrant box add user/namebox)
- démarrer la box
vagrant up vagrant ssh
- détruire l'instance d'une box
vagrant destroy
- deinstaller une box
vagrant box remove
synced folders (/vagrant)
By default, Vagrant shares your project directory (remember, that is the one with the Vagrantfile) to the /vagrant directory in your guest machine.
vagrant up vagrant ssh vagrant@precise64:~$ ls /vagrant Vagrantfile
Provisioning
in the same directory as your Vagrantfile:
vim bootstrap.sh #!/usr/bin/env bash apt-get update apt-get install -y apache2 if ! [ -L /var/www ]; then rm -rf /var/www ln -fs /vagrant /var/www fi
vim vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision :shell, path: "bootstrap.sh" end
vagrant up or vagrant reload --provision
Networking
Let us setup a forwarded port so we can access Apache in our guest:
vim Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision :shell, path: "bootstrap.sh" config.vm.network :forwarded_port, guest: 80, host: 4567 end vagrant reload or vagrant up
Vagrant also has other forms of networking, allowing you to assign a static IP address to the guest machine, or to bridge the guest machine onto an existing network. If you are interested in other options, read the networking page.
Créer un compte gratuit sur https://www.vagrantup.com/docs/other/atlas.html
vagrant login vagrant share
Stop VM
With Vagrant, you suspend, halt, or destroy the guest machine.
vagrant suspend or vagrant halt or vagrant destroy (Again, when you are ready to work again, just issue a vagrant up. The benefit of this is that no cruft is left on your machine.)
Liste de VM et status
vagrant status or vagrant status vmname
Plugins
vagrant plugin list vagrant plugin install <name>... vagrant plugin update vagrant plugin update [<name>] vagrant plugin license <name> <license-file> vagrant plugin uninstall <name> [<name2> <name3> ...]