gpt4 book ai didi

vagrant - 如何在配置时解锁 Vagrant 机器

转载 作者:行者123 更新时间:2023-12-01 03:40:09 29 4
gpt4 key购买 nike

vagrant up 时,我们的 vagrant box 需要大约 1 小时才能提供第一次运行,在配置过程的最后,我想将盒子打包到本地文件夹中的图像,以便下次需要重建时将其用作基础盒子。我正在使用 vagrant-triggers 插件将代码放在 :up 过程的末尾。

相关(缩短)Vagrantfile:

pre_built_box_file_name = 'image.vagrant'
pre_built_box_path = 'file://' + File.join(Dir.pwd, pre_built_box_file_name)
pre_built_box_exists = File.file?(pre_built_box_path)
Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.box_url = pre_built_box_path if pre_built_box_exists
config.trigger.after :up do
if not pre_built_box_exists
system("echo 'Building gett vagrant image for re-use...'; vagrant halt; vagrant package --output #{pre_built_box_file_name}; vagrant up;")
end
end
end

问题是 vagrant 在当前( vagrant up )进程运行时锁定了机器:
An action 'halt' was attempted on the machine 'gett',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.

我了解在一个给定时间配置或修改机器的两个进程的危险,但这是一种特殊情况,我确定配置已完成。

如何在配置期间手动“解锁” Vagrant 机器,以便我可以运行 vagrant halt; vagrant package; vagrant up;从内部 config.trigger.after :up ?

或者至少有一种方法可以启动 vagrant up不锁机?

最佳答案

Vagrant

此问题已在 GH #3664 中得到修复(2015)。如果仍然发生这种情况,可能与插件(例如 AWS)有关。所以尝试不使用插件。

Vagrant

如果您使用的是 AWS,请遵循此错误/功能报告:#428 - Unable to ssh into instance during provisioning ,目前正在等待中。

但是有一个 pull request 可以解决这个问题:

  • Allow status and ssh to run without a lock #457

  • 所以手动应用修复,或者等到它在下一个版本中修复。

    如果您遇到与无效机器相关的错误,请尝试运行 vagrant global-status --prune命令。

    关于vagrant - 如何在配置时解锁 Vagrant 机器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31479456/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com