如何配置在多机 vagrant 文件中创建的 VM。我想在创建的每台机器上执行单独的 shell 配置脚本。我无法弄清楚 vagrant 是如何促成这一点的。
$kitCoreScript = <<SCRIPT
set -e
set -x
mkdir kitCoreFolder
exit
SCRIPT
$agentScript = <<SCRIPT
set -e
set -x
mkdir agentFolder
exit
SCRIPT
Vagrant.configure(2) do |config|
config.ssh.private_key_path = "rack_rsa"
config.vm.define "kitcore" do | kitcore |
kitcore.vm.provider :rackspace do |rs|
rs.username = "username"
rs.api_key = "1232134rewf324e2qede132423"
rs.admin_password = "pass1"
rs.flavor = /1 GB Performance/
rs.image = /Ubuntu 12.04/
rs.rackspace_region = :dfw
rs.server_name = "kit-core"
rs.public_key_path = "rack_rsa.pub"
end
kitcore.provision :shell, :inline => $kitCoreScript
end
config.vm.define "agents" do |agents|
agents.vm.provider :rackspace do |rs|
rs.username = "username"
rs.api_key = "2314rwef45435342543r"
rs.admin_password = "pass1"
rs.flavor = /1 GB Performance/
rs.image = /Ubuntu 12.04/
rs.rackspace_region = :dfw
rs.server_name = "agnet"
rs.public_key_path = "rack_rsa.pub"
end
agent.provision :shell, :inline => $agentScript
end
end
显然,在运行上述 vagrant 脚本时,我从 vagrant 收到以下错误消息。
dev-setup-scripts vagrant up
There are errors in the configuration of this machine. Please fix
the following errors and try again:
Vagrant:
* Unknown configuration section 'provision'.
非常感谢任何帮助。