-
Notifications
You must be signed in to change notification settings - Fork 6
/
Vagrantfile
144 lines (120 loc) · 5.7 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
# -*- mode: ruby -*-
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 2'
ENV['EVENT_NAME'] = ENV['EVENT_NAME'] || 'super'
ENV['EVENT_YEAR'] = ENV['EVENT_YEAR'] || '2019'
if Vagrant::Util::Platform.windows?
ENV['IS_VAGRANT_WINDOWS'] = 'true'
else
ENV['IS_VAGRANT_WINDOWS'] = 'false'
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/ubuntu-18.04'
config.vm.hostname = 'localhost'
config.vm.network :forwarded_port, guest: 8000, host: 8000 # haproxy http proxy
config.vm.network :forwarded_port, guest: 4443, host: 4443 # haproxy https proxy
config.vm.network :forwarded_port, guest: 8282, host: 8282 # cherrypy backend
config.vm.network :forwarded_port, guest: 8089, host: 8089 # locust performance testing (not turned on by default)
config.vm.synced_folder '.', '/home/vagrant/reggie-formula', create: true
# No good can come from updating plugins.
# Plus, this makes creating Vagrant instances MUCH faster.
if Vagrant.has_plugin?('vagrant-vbguest')
config.vbguest.auto_update = false
end
# This is the most amazing module ever, it caches anything you download with apt-get!
# To install it: vagrant plugin install vagrant-cachier
if Vagrant.has_plugin?('vagrant-cachier')
# Configure cached packages to be shared between instances of the same base box.
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :box
end
config.vm.provider :virtualbox do |vb|
vb.memory = 1536
vb.cpus = 2
if Vagrant::Util::Platform.windows?
# don't use colons (:) or parens in windows filenames, will cause vagrant up to fail
vb.name = 'reggie %s %s %s' % [ENV['EVENT_NAME'], ENV['EVENT_YEAR'], Time.now.strftime('%Y-%m-%d %s')]
else
vb.name = 'reggie (%s %s) %s' % [ENV['EVENT_NAME'], ENV['EVENT_YEAR'], Time.now.strftime('%Y-%m-%d %H:%M:%S.%L')]
end if
# Allow symlinks to be created in /home/vagrant/reggie-formula.
# Modify "home_vagrant_reggie-formula" to be different if you change the path.
# NOTE: requires Vagrant to be run as administrator for this to work.
vb.customize ['setextradata', :id, 'VBoxInternal2/SharedFoldersEnableSymlinksCreate/home_vagrant_reggie-formula', '1']
end
config.vm.provision :shell, env: {
'EVENT_NAME'=>ENV['EVENT_NAME'],
'EVENT_YEAR'=>ENV['EVENT_YEAR'],
'IS_VAGRANT_WINDOWS'=>ENV['IS_VAGRANT_WINDOWS']
}, inline: "
set -e
# Upgrade all packages to the latest version - this is VERY SLOW on Windows, so Windows users are advised to comment this out
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
sudo -E apt-get -qy update
sudo -E apt-get -qy -o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-confold' upgrade
sudo -E apt-get -qy autoclean
# Install some prerequisites
sudo -E apt-get -qy install libssh-dev python-git swapspace python3-pygit2
# Create a sparse checkout of the infrastructure repo with only the reggie_config and reggie_state dirs
if [ ! -d '/home/vagrant/reggie-formula/infrastructure/.git' ]; then
git init /home/vagrant/reggie-formula/infrastructure
cd /home/vagrant/reggie-formula/infrastructure
git remote add origin https://github.com/magfest/infrastructure.git
git config core.sparsecheckout true
echo '/docs/*' >> .git/info/sparse-checkout
echo '/reggie_config/*' >> .git/info/sparse-checkout
echo '/reggie_state/*' >> .git/info/sparse-checkout
echo '/README.md' >> .git/info/sparse-checkout
git pull --depth=1 origin master
git branch --set-upstream-to=origin/master master
fi
# Set up event grains
mkdir -p /etc/salt
cat > /etc/salt/grains <<ENDGRAINS
event_name: ${EVENT_NAME}
event_year: ${EVENT_YEAR}
is_vagrant_windows: ${IS_VAGRANT_WINDOWS}
ENDGRAINS
"
config.vm.provision :salt do |salt|
salt.install_master = true
salt.install_type = 'git'
salt.install_args = 'v2019.2.0'
salt.seed_master = {reggie: 'vagrant/vagrant/files/reggie.pub'}
salt.master_config = 'vagrant/vagrant/files/salt_master.yaml'
salt.minion_config = 'vagrant/vagrant/files/salt_minion.yaml'
salt.minion_id = 'reggie'
salt.minion_key = 'vagrant/vagrant/files/reggie.pem'
salt.minion_pub = 'vagrant/vagrant/files/reggie.pub'
salt.run_highstate = false
salt.orchestrations = ['orchestration.vagrant_up']
salt.colorize = true
salt.log_level = 'info'
salt.verbose = true
end
config.vm.post_up_message = "
All done!
event_name: #{ENV["EVENT_NAME"]}
event_year: #{ENV["EVENT_YEAR"]}
To login to your new development machine run:
vagrant ssh
The machine is configured using salt (minion id is 'reggie'):
sudo salt reggie state.apply
Shortcut aliases have been installed for you:
alias run_server='reggie-formula/reggie_install/env/bin/python reggie-formula/reggie_install/run_server.py'
The reggie virtualenv has been added to your path, along with a custom python startup:
export PYTHONSTARTUP=\"/home/vagrant/.pythonstartup.py\"
export PATH=\"reggie-formula/reggie_install/env/bin:$PATH\"
The following services have been installed with systemd:
reggie
+- reggie-web
+- reggie-worker
+- reggie-scheduler
You can access the web interface at:
https://localhost:4443
Username: magfest@example.com
Password: magfest
"
end