-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVagrantfile
50 lines (42 loc) · 1.71 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
require 'yaml'
# Check required plugins
required_plugins = [ 'vagrant-aws' ]
required_plugins.each do |plugin|
unless Vagrant.has_plugin?(plugin)
system("vagrant plugin install #{plugin}")
end
end
# Load global config
$configuration = YAML.load_file('configuration.yaml')
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
$configuration['nodes'].each do |key, val|
config.vm.define val['hostname'] do |node|
node.vm.box = $configuration['config.vm.box']
node.vm.box_url = $configuration['config.box_url']
node.vm.hostname = val['hostname']
node.vm.provider "aws" do |aws|
aws.security_groups = val['securitygroup']
aws.tags = val['tags']
aws.instance_type = val['instance_type']
end
end
end
config.vm.provider :aws do |aws, override|
aws.access_key_id = $configuration['aws.access.key_id']
aws.secret_access_key = $configuration['aws.secret_access_key']
aws.keypair_name = $configuration['aws.keypair_name']
aws.region = $configuration['aws.region']
aws.ami = $configuration['aws.ami']
aws.block_device_mapping = [{
'DeviceName' => $configuration['aws.block_device_mapping']['DeviceName'],
'Ebs.VolumeSize' => $configuration['aws.block_device_mapping']['Ebs.VolumeSize'],
'Ebs.DeleteOnTermination' => $configuration['aws.block_device_mapping']['Ebs.DeleteOnTermination']
}]
override.ssh.username = $configuration['override.ssh.username']
override.ssh.private_key_path = $configuration['override.ssh.private_key_path']
end
end