-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
92 lines (77 loc) · 3.08 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#*******************************************************************************
# PACKAGES
#*******************************************************************************
require "vagrant-aws"
require "yaml"
#*******************************************************************************
# REQUIREMENTS
#*******************************************************************************
Vagrant.require_version ">= 1.9.1"
VAGRANTFILE_API_VERSION = "2"
ENV["VAGRANT_DEFAULT_PROVIDER"] = "aws"
PROJECT_NAME = "crimegraph"
inventory = YAML.load_file(File.join(File.dirname(__FILE__), "inventory.yaml"))
ansible_groups = {}
inventory.each do |cluster|
ansible_groups[cluster["name"]] = []
cluster["instances"].each do |instance|
ansible_groups[cluster["name"]] << instance["name"]
end
end
#*******************************************************************************
# CONFIGURATION
#*******************************************************************************
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
aws.region = "eu-west-1"
end # config.vm.provider aws
inventory.each do |cluster|
cluster["instances"].each do |instance|
config.vm.define instance["name"] do |srv|
srv.vm.provider :aws do |aws, override|
aws.instance_type = instance["type"]
aws.ami = instance["ami"]
aws.security_groups = instance["security_groups"]
aws.tags = {
"Name" => instance["name"],
"Project" => PROJECT_NAME
}
override.ssh.username = instance["user"]
override.ssh.private_key_path = ENV["AWS_KEYPAIR_PATH"]
end # config.vm.provider aws
srv.vm.synced_folder ".", "/vagrant", disabled: true
srv.vm.synced_folder "data/common", "/vagrant/data/common",
id: "data_common",
disabled: false,
type: "rsync",
create: true
srv.vm.synced_folder "data/" + cluster["name"] + "/common", "/vagrant/data/cluster",
id: "data_cluster",
disabled: false,
type: "rsync",
create: true
srv.vm.synced_folder "data/" + cluster["name"] + "/" + instance["name"], "/vagrant/data/instance",
id: "data_instance",
disabled: false,
type: "rsync",
create: true
if instance["name"] === "flink_master" then
srv.vm.synced_folder "target", "/vagrant/target",
id: "target",
disabled: false,
type: "rsync",
create: true
end # if instance["name"] === "flink_master"
end # config.vm.define instance[name]
end # cluster.each do instance
end # inventory.each do cluster
config.vm.provision :ansible do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.groups = ansible_groups
ansible.verbose = true
end # config.vm.provision ansible
end # Vagrant.configure