我正在尝试在本地Windows-10 mashine上使用Hyper-V设置一个vagrantbox。我的工作站在代理后面运行,但是我配置了本地cntlm代理来解决这些限制。代理设置可以正常工作,因为我能够安装无业游民的插件并借用箱形图像。
但是现在我的来宾Linux无法启动,并且我的构想已经耗尽。
我的流浪文件
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04" # ubuntu 18.04 image with support for virtual box and Hyper-V
config.vm.hostname = "skywalker"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.provider "hyperv" do |hv|
hv.memory = "2048"
end
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" # prevent tty errors
# install the vagrant plugin "vagrant-cachier" to cache downloaded artifacts
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# vagrant behing local cntlm proxy if plugin exists (= provinzial win10 workstation)
if !Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://localhost:3128/"
config.proxy.https = "http://localhost:3128/"
config.proxy.no_proxy = "localhost, 127.0.0.1"
end
# --------------------------------------------------------------------------
# provision virtual mashine (basic setup) and install applications in VM
#config.vm.provision "shell", path: "scripts/install-ansible.sh"
config.vm.provision "shell", path: "scripts/install-ncdu.sh"
config.vm.provision "shell", path: "scripts/install-git.sh"
config.vm.provision "shell", path: "scripts/install-openjdk-11.sh"
config.vm.provision "shell", path: "scripts/install-maven.sh"
config.vm.provision "shell", path: "scripts/install-node-npm.sh"
config.vm.provision "shell", path: "scripts/install-docker.sh"
config.vm.provision "shell", path: "scripts/install-docker-compose.sh"
# npm webserver
config.vm.provision "shell", path: "apps/install-npm-apps.sh"
config.vm.network "forwarded_port", guest: 8000, host: 8000
# artifactory setup (start artifactory after vm startup)
config.vm.network "forwarded_port", guest: 8081, host: 8081 # artifactory from docker
config.vm.network "forwarded_port", guest: 8082, host: 8082 # artifactory from docker
# See README.md for Artifactory in Docker
end
使用此设置打开框会导致
C:\home\work\workspace\vagrant-boxes\skywalker (master -> origin)
λ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: Importing a Hyper-V instance
default: Creating and registering the VM...
default: Successfully imported VM
default: Configuring the VM...
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: fe80::215:5dff:fe02:8b01
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: fe80::215:5dff:fe02:8b01:22
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
在将VirtualBox作为VM提供程序的另一个mashine上,此Vagrantfile可以正常工作。遗憾的是,由于无法控制的限制,我无法在Windows mashine上使用Hyper-V以外的任何VM提供程序...
我使用Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
设置了Hyper-V。
有什么想法吗?在此先感谢您,并致以最诚挚的问候。塞巴斯蒂安
答案 0 :(得分:0)
我上周进行了此练习,发现了类似的问题。按照这些步骤,我取得了很大的进步,并且在Windows 10 hyper-v下的合理时间启动了vm。这就是我所做的。
关注此博客,并尝试首先成功创建虚拟机。 https://win32.io/posts/Vagrant-Install-HyperV
然后,我创建了一个简单的vagrantfile,并使其成功运行。这是我的,
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/bionic64"
config.vm.hostname = 'utility-server-1'
config.vm.network 'public_network', bridge: 'Internet'
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider "hyperv" do |vb|
vb.memory = "4024"
vb.cpus = 2
vb.vmname = 'utility-server-1'
end
end
一旦成功,请从您的vagrantfile中添加更复杂的步骤,例如shell脚本和转发的端口。