如何在配置时解锁流浪汉机器

时间:2015-07-17 15:33:54

标签: vagrant vagrantfile

我们的流浪盒需要约1小时才能配置,因此当第一次运行vagrant up时,在配置过程的最后,我想将盒子打包到本地文件夹中的图像,这样就可以了在下次需要重建时用作基本框。我正在使用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 up)进程正在运行时,vagrant会锁定机器:

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 halt; vagrant package; vagrant up;内运行config.trigger.after :up

或者至少有一种方法可以在不锁定机器的情况下启动vagrant up吗?

1 个答案:

答案 0 :(得分:1)

流浪

此问题已在GH #3664(2015)中修复。如果这仍然发生,可能它与插件(例如AWS)有关。所以试试没有插件。

流浪-AWS

如果您正在使用AWS,请按照此错误/功能报告:#428 - Unable to ssh into instance during provisioning进行操作。

但是有一个拉取请求可以解决问题:

因此,请手动应用此修复程序,或等待它在下一版本中修复。

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