背景 我的团队分发通过流浪汉提供的盒子。这些盒子经常用作底盒,需要额外的配置。 MacOSX 10.9.3上的Vagrant版本为1.6.3。
问题: vagrant检测到该框始终是配置的,默认情况下会跳过配置阶段,除非通过--provision或vagrant配置强制执行。我希望团队使用以前配置的框与分布式框进行交互,而无需使用提供标记。
问题: 如何检测并重置盒子的配置状态,以便它默认重新运行配置器?
示例:
示例Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "chef/centos-6.5"
config.vm.provision "shell", inline: "echo Hello, World"
end
最初的流浪汉:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'chef/centos-6.5'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: example-delme_default_1409678677244_49440
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2202 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2202
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/user/temp/example-delme
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Hello, World
第二个流浪汉:
$ vagrant halt -f && vagrant up
==> default: Forcing shutdown of VM...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2202 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2202
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/user/temp/example-delme
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
问题显示在控制台输出“Machine already provisioned”中。