ubuntu - 在 Ubuntu 上的 VirtualBox 上的 Vagrant

标签 ubuntu vagrant windows-10 virtualbox hyper-v

我需要构建 Vagrantfile。而且我需要使用 Ansible(所以,我不能使用 Windows)。

但我的主要操作系统 - Windows 10。我可以在 Hyper-V 或 VirtualBox 上安装 Ubuntu。

1) 我创建 Hyper-V 机器并在其上安装 Ubuntu。但是 vagrantfile 不能使用 hyper-v 作为提供者,需要 virtualbox。

2) 如果我尝试在 VirtualBox 上启动虚拟 Ubuntu,我有一个错误

Failed to open a session for the virtual machine Ubuntu.

AMD-V is not available (VERR_SVM_NO_SVM).

Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

2) 如果我在 Windows 上关闭 Hyper-V,我可以在 VirtualBox 上启动 Ubuntu。

但是当我尝试 vagrant up ,我有一个错误:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "4e3f95fd-2ad3-423f-a39a-ffd65cfe0d46", "--type", 
"headless"]

Stderr: VBoxManage: error: AMD-V is not available (VERR_SVM_NO_SVM)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component 
ConsoleWrap, interface IConsole

在 VirtualBox 设置中启用 AMD-V/VT-x screenshot

是否有机会在虚拟 Ubuntu 上与 vagrant 合作?将真正的主系统从 Windows 更改为 Ubuntu 是不可取的。

谢谢你的帮助!

更新。我可以添加我的 virtualbox 和 BIOS 屏幕截图,也许它会有用。

虚拟盒子:

这是我的 Ubuntu 机器:Screenshot

AMD-V 已启用:Screenshot

BIOS:
https://s8.hostingkartinok.com/uploads/images/2017/07/4fe67600624d20d8194edc3d9224db69.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/6f05e15236404042ff929ad10280a1d1.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/23e417ab2fb13191780417030960cb82.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/fbcd47ad170ece6127592a6ca8d7dad5.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/65de25614774edc4f19506c8c10c61fe.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/ca73abc19ee7d82398f0574cf77789b4.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/8a15b5e490b285c41268cd4f6b0930c3.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/9c52e945ad8efc009b772b3e88f5672e.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/3357dd1540a2ea57e308a59ae41cf0af.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/311e96617a120ec3f22f4fe6833d3dc1.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/4963e3b283d1209e4e88a6b14d133dcd.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/628f1138d22dfc8b03a20def857e7967.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/36f8ba9c6a7806914f49b57fceaf7061.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/5a4df9d13773147f691e6ab3b244a547.jpg

结果,我成功配置了unix子系统,并安装了vbox、vagrant和ansible。但是当我输入 vagrant up我懂了
VirtualBox is complaining that the installation is incomplete. Please run 
VBoxManage --version to see the error message which should contain 
instructions on how to fix this error. 

所以,我运行 VBoxManage --version并且有
The character device /dev/vboxdrv does not exist. Please install the 
virtualbox-dkms package and the appropriate headers, most likely linux-
headers-3.4.0+. You will not be able to start VMs until this problem is 
fixed   

如果我尝试 apt-get install virtualbox-dkms它说最新版本已安装。

最佳答案

事实上,您可以使用 Windows(有点)。至少,对于 Ansible,您不需要完整的 Linux VM。尝试查看在 Windows 10 中运行适用于 Linux 的 Windows 子系统,它允许您从那里使用 Ansible。

您可以为 Windows 安装 Vagrant,它将支持 Hyper-V 提供程序。现在从 Windows 上的 Bash,您可以同时使用:Linux ansible 二进制文件和 windows vagrant.exe(它将启动您的常规 Windows 控制台),两者都在该 bash shell 内。

enter image description here

我以这种方式非常方便地使用 Ansible,并且我刚刚测试了从 bash 启动 Windows 进程。

enter image description here

根据上面的屏幕截图,您的 Windows 主机上的任何逻辑驱动器都可以通过 /mnt/drive_letter/ 访问。这就是你可以称之为 Vagrant 的方式。
因此,您的工作流程将是:

  • 安装 WSL
  • 在 WSL 中安装 Ansible
  • 在 Windows 中启用 Hyper-V 组件
  • 为 Windows 安装 Vagrant
  • 创建管理 vagrantfile 的剧本(使用 Hyper-V
    提供者)并调用“vagrant.exe up”

  • 当 ansible-playbook 运行时,它应该根据你的 vagrantfile 启动 Hyper-V VM。此设置允许您在主机和 vagrant 机器之间获得任何类型的网络连接,包括使用来自 WSL 的 Ansible 管理这些虚拟机,同时让剧本靠近您的 Windows 核心,如果您愿意,还可以使用 Notepad++ 编辑它们:)

    这里有一个站点,可以通过一些示例和详细步骤帮助将 Vagrant 和 Hyper-V 结合起来:Vagrant up on Windows 10 with Hyper-V

    关于ubuntu - 在 Ubuntu 上的 VirtualBox 上的 Vagrant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45217044/

    相关文章:

    已分配 Vagrant + Hyper V IPV6 地址

    ubuntu - Octave:可以编译 mex,但出现错误: "failed to install .mex file function"

    vagrant - 在远程 Vagrant 盒子上运行 Ansible playbook

    mongodb - 无法连接到在 Ubuntu 机器上运行的 mongodb

    vagrant - 增加特定 vagrant box 的内存

    makefile - 找不到 CMAKE_C_COMPILER

    c# - 已发布的 ClickOnce 应用程序未出现在“开始”菜单中

    c++ - vkWaitForFences 和 vkDeviceWaitIdle 不等待

    linux - Nagios Web 界面访问,在本地主机上没有斜杠

    ubuntu - 无法连接到服务器 : eof in kubernetes