Alex Cohen Alex Cohen - 2 months ago 14
Bash Question

Vagrant 1.8.4, cant run provisioner shell from a file

I had to downgrade my vagrant version do to conflicts with chef. Now I am using Vagrant 1.8.4, but I have encountered a problem with the provisioner function. This function should use the

bootstrap.sh
file that is present in the same directory as my vagrant file to bootstrap the instance I am creating. Here is my 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


When running
vagrant up
I get the following error:

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"
^


What is the correct syntax for using a provisioner file in Vagrant 1.8.4?

Answer

There's 2 ways to write it in ruby

config.vm.provision "shell", path: "bootstrap.sh"

or you could write

config.vm.provision :shell, :path => "bootstrap.sh"