2015-01-17 12 views
9

Ich versuche Vagrant zu lernen, indem ich das Tutorial für Anfänger durchführe. Aber nur ein paar Schritte in das Tutorial funktionieren die Dinge schon nicht wie im Tutorial erklärt. Insbesondere sieht es so aus, als ob Vagrant nicht weiß, wie die im Tutorial verwendete Box heruntergeladen werden soll. Hier ist, was ich bisher getan:Wie lautet die URL, die im Befehl zum Hinzufügen von Landstreichern verwendet werden soll?

Prüfen Sie, ob vagrant installiert ist:

$ which vagrant 

Vagrant Install:

$ sudo aptitude install vagrant 
The following NEW packages will be installed: 
    bsdtar{a} libruby1.9.1{a} libyaml-0-2{a} ruby{a} ruby-childprocess{a} ruby-erubis{a} ruby-ffi{a} ruby-i18n{a} ruby-log4r{a} ruby-net-scp{a} ruby-net-ssh{a} ruby1.9.1{a} vagrant 
0 packages upgraded, 13 newly installed, 0 to remove and 5 not upgraded. 
Need to get 0 B/3,451 kB of archives. After unpacking 17.9 MB will be used. 
Do you want to continue? [Y/n/?] y 
Selecting previously unselected package libyaml-0-2:amd64. 
(Reading database ... 171235 files and directories currently installed.) 
Preparing to unpack .../libyaml-0-2_0.1.4-3ubuntu3.1_amd64.deb ... 
Unpacking libyaml-0-2:amd64 (0.1.4-3ubuntu3.1) ... 
Selecting previously unselected package bsdtar. 
Preparing to unpack .../bsdtar_3.1.2-7ubuntu2_amd64.deb ... 
Unpacking bsdtar (3.1.2-7ubuntu2) ... 
Selecting previously unselected package ruby. 
Preparing to unpack .../ruby_1%3a1.9.3.4_all.deb ... 
Unpacking ruby (1:1.9.3.4) ... 
Selecting previously unselected package ruby1.9.1. 
Preparing to unpack .../ruby1.9.1_1.9.3.484-2ubuntu1.2_amd64.deb ... 
Unpacking ruby1.9.1 (1.9.3.484-2ubuntu1.2) ... 
Selecting previously unselected package libruby1.9.1. 
Preparing to unpack .../libruby1.9.1_1.9.3.484-2ubuntu1.2_amd64.deb ... 
Unpacking libruby1.9.1 (1.9.3.484-2ubuntu1.2) ... 
Selecting previously unselected package ruby-ffi. 
Preparing to unpack .../ruby-ffi_1.9.3debian-1ubuntu2_amd64.deb ... 
Unpacking ruby-ffi (1.9.3debian-1ubuntu2) ... 
Selecting previously unselected package ruby-childprocess. 
Preparing to unpack .../ruby-childprocess_0.3.9-2_all.deb ... 
Unpacking ruby-childprocess (0.3.9-2) ... 
Selecting previously unselected package ruby-erubis. 
Preparing to unpack .../ruby-erubis_2.7.0-2_all.deb ... 
Unpacking ruby-erubis (2.7.0-2) ... 
Selecting previously unselected package ruby-i18n. 
Preparing to unpack .../ruby-i18n_0.6.9-1_all.deb ... 
Unpacking ruby-i18n (0.6.9-1) ... 
Selecting previously unselected package ruby-log4r. 
Preparing to unpack .../ruby-log4r_1.1.10-3_all.deb ... 
Unpacking ruby-log4r (1.1.10-3) ... 
Selecting previously unselected package ruby-net-ssh. 
Preparing to unpack .../ruby-net-ssh_1%3a2.6.8-1_all.deb ... 
Unpacking ruby-net-ssh (1:2.6.8-1) ... 
Selecting previously unselected package ruby-net-scp. 
Preparing to unpack .../ruby-net-scp_1.1.1-1_all.deb ... 
Unpacking ruby-net-scp (1.1.1-1) ... 
Selecting previously unselected package vagrant. 
Preparing to unpack .../vagrant_1.4.3-1_all.deb ... 
Unpacking vagrant (1.4.3-1) ... 
Processing triggers for man-db (2.6.7.1-1ubuntu1) ... 
Processing triggers for doc-base (0.10.5) ... 
Processing 1 added doc-base file... 
Registering documents with scrollkeeper... 
Setting up libyaml-0-2:amd64 (0.1.4-3ubuntu3.1) ... 
Setting up bsdtar (3.1.2-7ubuntu2) ... 
Setting up ruby (1:1.9.3.4) ... 
Setting up ruby1.9.1 (1.9.3.484-2ubuntu1.2) ... 
Setting up libruby1.9.1 (1.9.3.484-2ubuntu1.2) ... 
Setting up ruby-ffi (1.9.3debian-1ubuntu2) ... 
Setting up ruby-childprocess (0.3.9-2) ... 
Setting up ruby-erubis (2.7.0-2) ... 
Setting up ruby-i18n (0.6.9-1) ... 
Setting up ruby-log4r (1.1.10-3) ... 
Setting up ruby-net-ssh (1:2.6.8-1) ... 
Setting up ruby-net-scp (1.1.1-1) ... 
Setting up vagrant (1.4.3-1) ... 
Processing triggers for libc-bin (2.19-0ubuntu6.5) ... 

Versuchen die vagrant getting started tutorial:

$ mkdir vagrant_getting_started && cd $_ 

$ 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. 

$ vagrant box add hashicorp/precise32 
This command was not invoked properly. The help for this command is 
available below. 

Usage: vagrant box add <name> <url> [--provider provider] [-h] 
    --checksum VALUE    Checksum 
    --checksum-type VALUE  Checksum type 
-c, --clean      Remove old temporary download if it exists. 
-f, --force      Overwrite an existing box if it exists. 
    --insecure     If set, SSL certs will not be validated. 
    --cacert certfile   CA certificate 
    --cert certfile    The client SSL cert 
    --provider provider   The provider that backs the box. 
-h, --help      Print this help 

Basierend auf Diese Ausgabe sieht so aus, als müsste ich eine URL angeben, von der die Box heruntergeladen werden kann. Also, basierend auf dem Tutorial, suchte ich Hashicorp's Atlas box catalog. Ich glaube, ich fand die richtige Ressource https://atlas.hashicorp.com/hashicorp/boxes/precise32, aber diese Ressource bietet keine URL, von der die Box abgerufen werden kann. Stattdessen sagt es nur vagrant up hashicorp/precise32 --provider virtualbox. Also habe ich versucht, diesen Befehl und habe diesen Fehler:

$ vagrant up hashicorp/precise32 --provider virtualbox 
The machine with the name 'hashicorp/precise32' was not found configured for 
this Vagrant environment. 

Wo man die URL findet, die in dem vagrant box add <name> <url> Befehl verwendet werden sollen? Ich dachte, es wäre leicht, das in Hashicorps Boxkatalog zu finden, aber ich sehe es nirgends.

Nur für den Fall sind diese hilfreichen Informationen über meine aktuelle Umgebung:

$ vagrant box list -i 
There are no installed boxes! Use `vagrant box add` to add some. 

Antwort

9

Ich denke, das Problem ist, dass Sie mit einer hübschen alten Version von Vagrant endeten - 1.4.3-1 während die neuesten 1.7 ist. 2. Es ist möglich, dass das von Ihnen installierte Repository nicht mehr auf dem neuesten Stand gehalten wird.

Ich empfehle, das zu deinstallieren, was Sie derzeit haben, und dann das neueste von Vagrant downloads neu zu installieren.

Update: Wenn Sie Vagrant auf Linux installieren, (entweder Debian oder RPM-Format Verpackung), werden Sie möchte auf jeden Fall von Vagrant downloads herunterladen, da die Pakete in Repositories sind nicht auf dem neuesten Stand gehalten werden und wird ganz sein alt.

Für Vagrant 1.7.2, die Box Hilfe hinzufügen sagt unter anderem:

$ vagrant box add -h 
Usage: vagrant box add [options] <name, url, or path> 

The box descriptor can be the name of a box on HashiCorp's Atlas, 
or a URL, or a local .box file, or a local .json file containing 
the catalog metadata. 

Dann können Sie entlang der Getting Started Guide folgende fortsetzen, und kann ein bisschen mehr auf dem Boxes documentation lesen.

Update 2: auf die ursprüngliche Frage: „Wie finde ich die URL für eine Box-Datei?“, Gibt es zwei Fälle:

  1. Schachteln aus HashiCorp, die nun auf ihre Atlas service gehostet werden: Diese sind durch die Abkürzungscodes wie "hashicorp/precise32" oder "ubuntu/trusty64" gekennzeichnet. Ich stelle mir vor, dass es einen Webservice oder eine Konvention gibt, bei der die Vagrant-Befehlszeile Atlas Cloud abfragen kann, um dann die tatsächliche Download-URL zu finden. Sie scheinen dies nicht öffentlich zu machen, aber Sie könnten es wahrscheinlich herausfinden, indem Sie den Netzwerkverkehr beobachten oder die Landstreicherquelle betrachten.

  2. Boxen von anderen Projekten, die öffentlich oder intern sein könnten (Firma): Diese würden normalerweise mit einer normalen URL kommen, die direkt auf die .box-Datei verweist. Sie können einige Beispiele von diesen auf Vagrantbox.es sehen. In der Tat, wenn Sie dort nach "vagrantup" suchen, werden Sie viele der ursprünglichen Standardboxen und ihre URLs sehen.

+1

ich auf Lubuntu 14.04.1 hatte das gleiche Problem-get apt mit installieren Vagabund (vagrant -v => 1.4.3). Vagrant scheint am besten zu funktionieren, wenn von der Quelle installiert? – user77115

+0

@ user77115 ja ich stimme zu - Ich habe meine Antwort aktualisiert, um klarzustellen, dass der beste Weg, um Vagrant zu bekommen, über die Downloads-Seite (oder kompilieren von Quelle, wie Sie notiert). Die Paket-Repos scheinen nicht mehr aktualisiert zu werden. – BrianC

+2

Ich wählte diese Antwort und markierte sie als die richtige Antwort, aber es fällt mir jetzt ein, dass, während diese Antwort nützlich ist, es die echte Frage umgeht, die ist, wie findet jemand die URL, um die Box zu holen? Ihre Antwort wäre besser, wenn sie speziell auf dieses Problem eingehen würde. – axiopisty

7

Es ist mir nicht klar, warum sollten Sie nicht nur vagrant init hashicorp/precise32 laufen, da dies die beiden Feststellung behandelt und das Hinzufügen der Box zu Ihrer Box-Registrierung.

Allerdings, wenn Sie wirklich sehen wollen, wo die Box kommt, auch mit älteren Versionen von vagrant, können Sie die Vorteile der --debug Flagge und Sie werden in der Ausgabe unter der Motorhaube sehen, dass diese URL Box derzeithttps://atlas.hashicorp.com/hashicorp/boxes/precise32/versions/1.0.0/providers/virtualbox.box.

die Frage zu beantworten (wenn auch nicht auf diese Weise empfohlen):

vagrant box add hashicorp/precise32 https://atlas.hashicorp.com/hashicorp/boxes/precise32/versions/1.0.0/providers/virtualbox.box

+0

Um zu erklären, warum ein Neuling zu Vagabund würde 'vagrant init hashicorp/precise32' nicht ausführen, ist der Grund, weil das Tutorial im OP nicht verknüpft, sagt es nicht, es so zu tun. Es sagt speziell: 'vagrant init' und dann' vagrant box add hashicorp/precise32'. Mit der in den Distro-Repos verfügbaren Version von vagrant verursachte dies den im OP angegebenen Fehler. Sicherlich ist dieser Ansatz eine andere Alternative für diejenigen, die die URL nicht kennen, und für diejenigen, die wissen, dass es sogar eine Option ist. Personen, die dem Lernprogramm folgen, verfügen möglicherweise nicht über diese Informationen. – axiopisty

0

mit:

~ » vagrant version 
Installed Version: 2.0.1 
Latest Version: 2.0.1 

You're running an up-to-date version of Vagrant! 

Sie eine Locke Anfrage einfach ausgeben können, zurück, um die Daten zu erhalten. Siehe unten:

~ » curl -i -L https://vagrantcloud.com/sakhan/ubuntu1404-contrail-devstack1 
HTTP/1.1 301 Moved Permanently 
Server: Cowboy 
Date: Fri, 19 Jan 2018 18:08:40 GMT 
Connection: keep-alive 
Location: https://vagrantcloud.com/sakhan/boxes/ubuntu1404-contrail-devstack1 
Content-Type: text/html 
Cache-Control: no-cache 
X-Request-Id: cfcc4360-34f5-41d2-91ce-1eb82e5a6b7c 
X-Runtime: 0.004783 
Content-Length: 133 
Via: 1.1 vegur 

HTTP/1.1 302 Found 
Server: Cowboy 
Date: Fri, 19 Jan 2018 18:08:40 GMT 
Connection: keep-alive 
X-Frame-Options: SAMEORIGIN 
X-Xss-Protection: 1; mode=block 
X-Content-Type-Options: nosniff 
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload 
Location: https://app.vagrantup.com/sakhan/boxes/ubuntu1404-contrail-devstack1 
Content-Type: text/html; charset=utf-8 
Cache-Control: no-cache 
X-Request-Id: 1383ab1f-8ed8-4e81-9762-d5ffacdda9f3 
X-Runtime: 0.008575 
Transfer-Encoding: chunked 
Via: 1.1 vegur 

HTTP/1.1 200 OK 
Server: Cowboy 
Date: Fri, 19 Jan 2018 18:08:41 GMT 
Connection: keep-alive 
X-Frame-Options: SAMEORIGIN 
X-Xss-Protection: 1; mode=block 
X-Content-Type-Options: nosniff 
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload 
Content-Type: application/json; charset=utf-8 
Etag: W/"af57ca8e837f7cdd4c3047e2752a506f" 
Cache-Control: max-age=0, private, must-revalidate 
X-Request-Id: b0296c54-8ffc-408b-89e5-e361df1bb6c8 
X-Runtime: 0.051198 
Transfer-Encoding: chunked 
Via: 1.1 vegur 

{"description":"Vagrant box having Opencontail + Devstack environment","short_description":"Vagrant box having Opencontail + Devstack environment","name":"sakhan/ubuntu1404-contrail-devstack1","versions":[{"version":"0.0.2","status":"active","description_html":"<p>Vagrant box with opencontrail_devstack version 0.0.2</p>\n","description_markdown":"Vagrant box with opencontrail_devstack version 0.0.2","providers":[{"name":"virtualbox","url":"https://vagrantcloud.com/sakhan/boxes/ubuntu1404-contrail-devstack1/versions/0.0.2/providers/virtualbox.box"}]}]} 

so am Ende, Sie haben die folgende json Info:

providers: 
    name: virtualbox 
    url: https://vagrantcloud.com/sakh...ons/0.0.2/providers/virtualbox.box 

HTH

Verwandte Themen