我正在学习 Udacity 课程,他们让我安装 Vagrant。但是由于 .box 文件很大,我首先从其他网络将它下载到本地,然后我得到了这个 tar 文件trusty-server-cloudimg-i386-vagrant-disk1.tar
。他们让我下载他们的文件夹fullstack
。该文件夹由以下结构组成:
|--fullstack
|--vagrant
|--.vagrant
|--catalog
|--forum
|--forum.py
|--forum.sql
|--forumdb.py
|--tournament
|--tournament.py
|--tournament.sql
|--tournament_test.py
|--pg_config
|--Vagrantfile
Vagrant 你可以从这个链接看到他们是怎么做的。现在,当我通过转到以下代码的位置使用时vagrant up
:git bash
fullstack/vagrant
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty32' could not be found. Attempting to find and in
stall...
default: Box Provider: virtualbox
defa
ult: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty32'
default: URL: https://atlas.hashicorp.com/ubuntu/trusty32
==> default: Adding box 'ubuntu/trusty32' (v20150818.0.0) for provider: virtualb
ox
现在,正如您在下面的代码中看到的那样,它正在尝试从在线下载 .box 文件,该文件我已在本地下载,并且我的驱动器上有该文件。我想编辑一些配置文件,这样当我使用vagrant up
它时应该使用本地文件trusty-server-cloudimg-i386-vagrant-disk1.tar
文件来安装,而不应该去下载在线文件
default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/20150818.0.0/providers/virtualbox.box
==> default: Box download is resuming from prior download progress
default: Progress: 0% (Rate: 13410/s, Estimated time remaining: 5:35:56))
如果仍然需要一些信息,请在评论中问我,我会更新我的问题。
流浪文件:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: "pg_config.sh"
# config.vm.box = "hashicorp/precise32"
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5000, host: 5000
end
pg_config.sh :
apt-get -qqy update
apt-get -qqy install postgresql python-psycopg2
apt-get -qqy install python-flask python-sqlalchemy
apt-get -qqy install python-pip
pip install bleach
pip install oauth2client
pip install requests
pip install httplib2
su postgres -c 'createuser -dRS vagrant'
su vagrant -c 'createdb'
su vagrant -c 'createdb forum'
su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'
vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m"
echo -e $vagrantTip > /etc/motd
当我尝试像这样添加时,出现以下错误:
$ vagrant box add mybox C:\Users\Rahul\Downloads\trusty-server-cloudimg-i386-va
grant-disk1.tar
c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize':
the scheme file does not accept registry part: C:UsersRahulDownloadstrusty-serv
er-cloudimg-i386-vagrant-disk1.tar (or bad hostname?) (URI::InvalidURIError)
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in `
new'
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in `
parse'
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:747:in `
parse'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:465:in `metadata_url?'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:77:in `block in call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:75:in `map'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:75:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/warden.rb:34:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builder.rb:116:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/runner.rb:66:in `block in run'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/u
til/busy.rb:19:in `busy'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/runner.rb:66:in `run'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma
nds/box/command/add.rb:89:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma
nds/box/command/root.rb:61:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/c
li.rb:42:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/e
nvironment.rb:301:in `cli'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:1
74:in `<main>'
编辑添加了一些错误:
$ vagrant box add mybox C:/Udacity/trusty-server-cloudimg-i386-vagrant-disk1.ta
r
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'mybox' (v0) for provider:
box: Unpacking necessary files from: file://C:/Udacity/trusty-server-cloudim
g-i386-vagrant-disk1.tar
box:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /Udacity/trusty-server-cloudimg-i386-vagrant-disk1.tar