-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
148 lines (121 loc) · 4.3 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "json"
def read(filename = "config.json")
file = nil
data = nil
if(!File.exist?(filename))
puts "File '#{filename}' does not exist."
return nil
end
begin
file = File.read(filename)
rescue
puts "Cannot read in '#{filename}' file."
return nil
end
begin
data = JSON.parse(file)
rescue
puts "Unable to parse JSON from '#{filename}' file."
return nil
end
return data
end
cfg = read
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Disable the default share of the current code directory. Doing this
# provides improved isolation between the vagrant box and your host
# by making sure your Vagrantfile isn't accessable to the vagrant box.
# If you use this you may want to enable additional shared subfolders as
# shown above.
config.vm.synced_folder ".", "/vagrant", disabled: true
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = cfg["virtual_machine"]["box"]
# The hostname the machine should have.
# If set to a string, the hostname will be set on boot.
# If set, Vagrant will update /etc/hosts on the guest with the configured hostname.
config.vm.hostname = cfg["virtual_machine"]["name"]
# Vagrant will check for updates to the configured box on every vagrant up.
# If an update is found, Vagrant will tell the user.
# By default this is true.
# Updates will only be checked for boxes that properly support updates.
config.vm.box_check_update = true
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: cfg["virtual_machine"]["ip"]
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
config.vm.provider "parallels" do |prl|
# You can customize the virtual machine name that appears in the Parallels Desktop GUI.
# By default, Vagrant sets it to the name of the folder containing the Vagrantfile plus a timestamp of when the machine was created.
prl.name = cfg["virtual_machine"]["name"]
# Full clone is a full image copy, which is totally independent from the box.
prl.linked_clone = false
# Sets the number of CPUs to be available to the virtual machine.
prl.cpus = cfg["virtual_machine"]["cpus"]
# Sets the amount of memory for the virtual machine (in megabytes).
prl.memory = cfg["virtual_machine"]["memory"]
# Automatically update Parallels tools.
prl.update_guest_tools = true
end
if cfg["options"]["is_docker"]
config.vm.provision "docker" do |d|
end
end
if cfg["options"]["is_minikube"]
config.vm.provision "minikube",
type: "shell",
path: "provisioners/install_minikube.sh",
privileged: false
end
if cfg["options"]["is_source_control"]
config.vm.provision "ssh",
type: "shell",
path: "provisioners/generate_ssh.sh",
args: cfg["email"],
privileged: false
config.vm.provision "git",
type: "shell",
path: "provisioners/install_git.sh",
args: [
cfg["name"],
cfg["email"]
],
privileged: false
config.vm.provision "github",
type: "shell",
path: "provisioners/install_github.sh",
args: [
cfg["github"]["title"],
cfg["github"]["token"]
],
privileged: false
end
if cfg["options"]["is_minikube"]
config.trigger.after :up do |trigger|
trigger.name = "minikube"
trigger.info = "Starting a cluster..."
trigger.run_remote = {
inline: "minikube start",
privileged: false
}
end
config.trigger.before :halt do |trigger|
trigger.name = "minikube"
trigger.info = "Stopping a cluster..."
trigger.run_remote = {
inline: "minikube stop",
privileged: false
}
end
end
end