【发布时间】:2017-06-28 13:19:54
【问题描述】:
我正在开始使用 Vagrant,并希望将它与 KVM/qemu(和 Virtual Machine Manager GUI)一起使用,而不是安装 VirtualBox。所以我先安装了 Vagrant:
$ vagrant --version
Vagrant 1.9.1
$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some
作为per these posts,我需要vagrant-libvirt 才能使其与KVM 一起使用,所以我接下来安装了它:
$ vagrant plugin list
vagrant-libvirt (0.0.37)
vagrant-share (1.1.6, system)
接下来,我使用vagrant box add "centos/7" 添加一个CentOS(7) 框,并在出现提示时选择libvirt。之后,我运行vagrant init 并没有遇到任何错误:
$ vagrant init centos/7
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 up 似乎出错了,如下所示:
$ vagrant up
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
-
这是
中的provider部分Vagrantfileconfig.vm.provider :libvirt do |domain| domain.driver = "qemu" domain.memory = 512 domain.cpus = 1 end -
我尝试将其修改为:
config.vm.provider :libvirt do |domain| domain.driver = "kvm" domain.host = 'localhost' domain.uri = 'qemu:///system' domain.memory = 512 domain.cpus = 1 end 我也试过
vagrant up --provider=kvm、vagrant up --provider=qemu和vagrant up --provider=libvirt,但无济于事。
有没有我遗漏的步骤?还是需要安装其他包/依赖项?
编辑: 使用 vagrant 添加centos/7 后,运行vagrant box list 时显示。
$ vagrant box list
centos/7 (libvirt, 1611.01)
【问题讨论】:
-
添加框后能否重新运行
vagrant box list -
@FrédéricHenri
centos/7出现在列表中。在问题中添加了输出 -
hum .. 你安装的 libvirt 和 qemu 工作正常吗?你能用
virsh或virt-manager创建qemu或kvm类型的虚拟机吗 -
@FrédéricHenri - 是的,虽然到目前为止我只将它与 GUI (VMM) 一起使用。
$ sudo virsh list显示正确的输出12 SS_Work running, like so
标签: vagrant qemu devops vagrantfile kvm