Swarup Donepudi
Swarup Donepudi

Reputation: 1004

Shell provisioning in a multi-machine vagrantfile

How do I provision VMs created in a multi-machine vagrant file. I want to execute separate shell provisioning scripts in each of the machines created. I am unable figure out how vagrant facilitates this.

$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

Apparently upon running the above vagrant script I get the below error message from 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'.

Any help is highly appreciated.

Upvotes: 1

Views: 646

Answers (1)

hek2mgl
hek2mgl

Reputation: 158210

You need to replace:

kitcore.provision 

by

kitcore.vm.provision

Do the same for the vm called agent.

Upvotes: 2

Related Questions