-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
129 lines (115 loc) · 4.82 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
ENV["VAGRANT_DISABLE_RESOLV_REPLACE"] = "1"
ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin" if RUBY_PLATFORM.include? "mingw" # Fix folder structure for Cygwin installations
ENV["VAGRANT_DEFAULT_PROVIDER"] = "virtualbox" # Use VirtualBox by default.
ENV["VAGRANT_PREFER_SYSTEM_BIN"] = "0" # Avoid conflicting versions of SSH with cygwin etc
ENV["VAGRANT_USE_VAGRANT_TRIGGERS"] = "1" #
ENV["VAGRANT_PREFER_SYSTEM_BIN"] = "1"
Vagrant.require_version ">= 2.1.0" # 2.1.0 required for vagrant triggers.
$config_folder = "#{File.dirname(__FILE__)}/VagrantConfig" # Folder where all required files are, escaping any spaces. Make sure this exists!!
$rsync_folder_excludes = { # Any folders that you don't want to rsync to the server.
"." => "/vagrant"
}
# ------------------ Vagrant Pre-Includes ------------------ #
# Functions and Project variables.
# ---------------------------------------------------------------- #
pre_includes = [
"#{$config_folder}/Project.rb", # Identifiers for this project e.g. repo location, costcentre
"#{$config_folder}/Functions.rb", # Helper functions
"#{$config_folder}/Plugins.rb" # Automatically installs plugins required for this vagrant installation.
]
pre_includes.each do |filename|
require filename # unless not File.exists?(filename)
end
$rsync_excludes = $rsync_excludes | ['node_modules/','dist/']
enforce_machine_name_requirement()
Ubuntu20_Official_amd64 = {
'box_url' => 'https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-vagrant.box',
'box_name' => 'ubuntu-20.04_amd64_official'
}
# Choose 1 of the above boxes for our local environment.
# Try swapping out for i386 version if your PC is a million years old and doesn't support VT-x.
VirtualBox = Ubuntu20_Official_amd64
# ------------------ Definitions ------------------
if File.file?("#{File.dirname(__FILE__)}/.env.rb") then
require "#{File.dirname(__FILE__)}/.env.rb"
end
puts "AscalonGW token is #{ENV["ASCALONGW-TOKEN"]}"
server_config = {
'is_local'=>0,
'is_production'=>0,
'is_cloud'=>0,
'is_aws'=>0,
'is_google'=>0,
'is_azure'=>0,
'is_rackspace'=>0,
'is_linode'=>0,
'deployment_date'=>Time.now.strftime("%Y%m%d%H%M%S"),
'repository_code_folder'=>'/home/vagrant/ascalongw-discord-bot',
'prefix' => '-',
'tokens' =>[
ENV["ASCALONGW-TOKEN"] || '',
ENV["KAMADANGW-TOKEN"] || ''
],
'owners' => ['379748158978392065'],
'channels' => {
'giveaways': '387595414259367939',
'pricecheck': '445966670016806951'
}
}
# ------------------ Vagrant Machine Definitions ------------------
# NB: If using password access, you'll need to add the ssh key manually because rsync doesn't play nice
# cat <local_public_key_location> | ssh <ssh_username>@<server_ip> "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Machines = {
'VirtualBox' => {
'local' => {
'hostnames' => ['local.gwascalon.com'], # With virtualbox, the first item is added to hosts file, then removed for further processing (see VagrantConfig/Functions.rb)
'server_config' => server_config.merge({
'tokens'=>[ENV["ASCALONGW-TOKEN-LOCAL"]],
'is_local'=>1
}),
'ip_address' => '10.10.10.52',
'deployment_script'=>'deploy.sh',
'code_to_provision' => 'local'
}
},
'ManagedServers' => {
'staging' => {
'ip_address' => '192.95.4.149',#'66.70.245.23',#'34.248.80.106',
'server_config' => server_config.merge({
'repository_code_folder'=>'/home/ubuntu/ascalongw-discord-bot',
'is_cloud'=>1
}),
'code_to_provision' => 'local',
#'rsync_path' => '~/local/bin/rsync', # Custom rsync binary on server.
'deployment_script'=>'deploy.sh',
'prompt_user_before_provision' => 0,
'ssh_username' => 'root',
#'ssh_password' => ENV['ASCALONGW-ROOT-PW'],
'os' => 'linux'
}
}
}
Vagrant.configure("2") do |config|
Machines['VirtualBox'].each do |machine_name,machine_properties|
config.vm.define machine_name do |machine|
machine.vm.box = VirtualBox['box_name']
machine.vm.box_url = VirtualBox['box_url'] || nil
machine.vbguest.auto_update = false
local_machine_setup(machine,machine_name,machine_properties);
end
config.vm.provider :virtualbox do |v, override|
#v.gui=true
v.customize ['modifyvm', :id, '--memory', machine_properties['server_memory_size'] || VirtualBox['server_memory_size'] || '1024']
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
end
end
# ------------------ Vagrant Post-Includes ------------------ #
# Provider specific details and VM provider setups.
# ---------------------------------------------------------------- #
post_includes = [
"#{$config_folder}/CloudProviderSetup.rb"
]
post_includes.each do |filename|
require filename # unless not File.exists?(filename)
end