与多个提供者一起使用vagrant的问题

时间:2014-11-20 17:18:53

标签: vagrant

我在这里遇到一个问题,试图提出一个流浪的提供者特定的盒子,我不知道该怎么做才能继续, 如果这是在文档中,那么我没有看到它?

我使用以下内容添加框

## Add the list of used Vagrant boxes
declare -A boxes
inc=1

boxes=(
  ['spherical64']='http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box'          ## Fedora           18      x64 nocm
  ['centos6464']='http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box'           ## CentOS           6.4     x64 nocm
  ['centos5964']='http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box'           ## CentOS           5.9     x64 nocm
  ['squeeze64']='http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box'           ## Debian           6.0.7   x64 nocm
  ['wheezy64']='http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box'          ## Debian           7.0rc1  x64 nocm
  ['sles11164']='http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box'           ## SUSE Enterprise  11sp1   x64 nocm
  ['lucid64']='http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box'    ## Ubuntu Server    10.04.4 x64 nocm
  ['precise64']='http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box'  ## Ubuntu Server    12.04.2 x64 nocm
)

set -e

for box in "${!boxes[@]}"; do
  echo "-- Installing: ${inc}/${#boxes[@]} ${box}"
  vagrant box add "${box}" "${boxes[$box]}"
  ((inc+=1))
done

set +e

然后尝试从那里流浪(在初始之后)

bash-4.3$ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'base' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
        default: Box Version: >= 0
    ==> default: Adding box 'base' (v0) for provider: virtualbox
        default: Downloading: base
    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 /private/tmp/base

bash-4.3$ vagrant box list
    centos5964  (virtualbox, 0)
    centos6464  (virtualbox, 0)
    lucid64     (virtualbox, 0)
    precise64   (virtualbox, 0)
    sles11164   (virtualbox, 0)
    spherical64 (virtualbox, 0)
    squeeze64   (virtualbox, 0)
    wheezy64    (virtualbox, 0)

bash-4.3$ vagrant up --provider=centos6464
    The provider 'centos6464' could not be found, but was requested to
    back the machine 'default'. Please use a provider that exists.

bash-4.3$ vagrant up --provider=virtualbox
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'base' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
        default: Box Version: >= 0
    ==> default: Adding box 'base' (v0) for provider: virtualbox
        default: Downloading: base
    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 /private/tmp/base

1 个答案:

答案 0 :(得分:1)

它试图在流浪者上使用一个基本盒(不存在)。所以答案实际上是在vagrant init上添加盒子名称。

bash-4.3$ vagrant init 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.

bash-4.3$ cat Vagrantfile |grep 'config.vm.box'
      config.vm.box = "precise64"

bash-4.3$ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Importing base box 'precise64'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Setting the name of the VM: tmp_default_1416506255173_95689
    ==> default: Clearing any previously set forwarded ports...
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 => 2222 (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: Warning: Connection timeout. Retrying...
    ==> 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.10
        default: VirtualBox Version: 4.3
    ==> default: Mounting shared folders...
        default: /vagrant => /private/tmp