1

我开始为开发创建一个新的虚拟机,因为我的 ubuntu 14.4 似乎已经过时了。

我决定将来切换到 ubuntu 17.10,但在第一次安装时失败。

这是我的流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.memory = "1024"
    end

    config.vm.box = "generic/ubuntu1710"
    config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: false
    config.vm.network "private_network", ip: "192.168.37.200"

end

在配置过程中我得到了这个

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown 'eth1' || true
/sbin/ip addr flush dev 'eth1'
# Remove any previous network modifications from the interfaces file
sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre
sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tac | sed -e '/^#VAGRANT-END/,$ d' | tac > /tmp/vagrant-network-interfaces.post

cat \
  /tmp/vagrant-network-interfaces.pre \
  /tmp/vagrant-network-entry \
  /tmp/vagrant-network-interfaces.post \
  > /etc/network/interfaces

rm -f /tmp/vagrant-network-interfaces.pre
rm -f /tmp/vagrant-network-entry
rm -f /tmp/vagrant-network-interfaces.post

/sbin/ifup 'eth1'

Stdout from the command:



Stderr from the command:

bash: line 4: /sbin/ifdown: No such file or directory
bash: line 20: /sbin/ifup: No such file or directory

该机器无法通过托管窗口使用。我必须在配置之前安装一些东西吗?或者您更喜欢 hashicorb 的其他机器模板?

问候 n00n

4

1 回答 1

6

Vagrant 目前无法与 Ubuntu 17.10 一起使用,因为删除了传统的网络配置工具和文件:/sbin/ifup/sbin/ifdown.

但是您可以使用以下解决方法创建具有网络接口的 vagrant VM:

1. 将安装添加ifupdown到您的 Vagrantfile 中:

# -*- mode: ruby -*-
# vi: set ft=ruby :

$provision_script = <<PROVISION
    apt-get -y update
    apt-get install ifupdown -y
PROVISION

Vagrant.configure("2") do |config|
    config.vm.provision "shell", inline: $provision_script
    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.memory = "1024"
    end

    config.vm.box = "generic/ubuntu1710"
    config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: false
    config.vm.network "private_network", ip: "192.168.37.200"
end

2. 创建流浪虚拟机:

vagrant up

当然,它会因相关错误而失败。

3. 在刚刚创建的虚拟机中启动配置脚本。ifupdown它安装包含必要文件的软件包:

vagrant provision

4. 现在重新加载你的虚拟机:

vagrant reload
于 2018-01-12T09:48:22.250 回答