我不得不将我的流浪汉版本降级为与厨师发生冲突。现在我正在使用Vagrant 1.8.4,但我遇到了配置函数的问题。此函数应使用与我的vagrant文件位于同一目录中的bootstrap.sh
文件来引导我正在创建的实例。这是我的Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
#gives the instances 1 extra network eth interfaces
config.vm.network "private_network", type: "dhcp"
#creates instances, defines linux image, hostname and a script to run on creation
config.vm.define "web1" do |web1|
web1.vm.box = "trusty64"
web1.vm.hostname = "web1"
#this will run the script bootstrap.sh that is in the same directory as the Vagrantfile
config.vm.provision :shell, path "bootstrap.sh"
end
end
运行vagrant up
时出现以下错误:
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:
/path/to/my/dir/Vagrantfile:14: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
config.vm.provision :shell, path "bootstrap.sh"
^
在Vagrant 1.8.4中使用配置文件的正确语法是什么?
答案 0 :(得分:1)
有两种方法可以在ruby中编写它
config.vm.provision "shell", path: "bootstrap.sh"
或者你可以写
config.vm.provision :shell, :path => "bootstrap.sh"