-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile.stack
58 lines (54 loc) · 2.15 KB
/
Vagrantfile.stack
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
$geonode_source_path='.'
$script1 = <<-'SCRIPT'
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo apt-get -f install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io pwgen python3-pip python3-virtualenv virtualenvwrapper
sudo adduser vagrant docker
SCRIPT
$script2 = <<-'SCRIPT'
if [ -d "/home/vagrant/generated-project" ]; then
cd /home/vagrant/generated-project
docker service rm geonode-stack
cd ..
rm -rf /home/vagrant/generated-project
fi
rm -rf /home/vagrant/geonode-project
SCRIPT
$script4 = <<-'SCRIPT'
sudo reboot
SCRIPT
Vagrant.configure(2) do |config|
boxes = {
'geonode-swarm' => 'ubuntu/focal64'
}
machine_id = 0
boxes.each do | key, value |
config.vm.network "forwarded_port", guest: 80, host: 8888
config.vm.provider "virtualbox" do |v|
v.memory = 8132
v.cpus = 4
v.name = "geonode-vm"
end
config.vm.box = "#{value}"
machine_id = machine_id + 1
config.vm.define "#{key}" do |node|
node.vm.hostname = "#{key}"
config.vm.provision "shell", inline: $script1, privileged: false
config.vm.provision "shell", inline: $script2, run: 'always', privileged: true
config.vm.provision "file", source: $geonode_source_path, destination: "$HOME/geonode-project", run: 'always'
config.vm.provision :shell, path: "generated-project-vagrant-swarm.sh", run: 'always', privileged: false
config.vm.provision "shell", inline: $script3, run: 'always', privileged: false
end
end
end