-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathVagrantfile
106 lines (83 loc) · 3.02 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 2.2.0"
CONFIG = Hash.new # GIS.lab configuration
CONFIG_VAGRANT = Hash.new # GIS.lab configuration for Vagrant (passed as Ansible extra vars)
# GIS.lab configuration
# Read default GIS.lab server machine configuration file
conf = YAML.load_file('system/group_vars/all')
conf.each do |key, value|
if not value.nil?
CONFIG[key] = value
end
end
# Read Configuration file for machine running under Vagrant provisioner.
# Use this file to override default GIS.lab configuration when
# using Vagrant provisioner.
if File.exist?('system/host_vars/gislab_vagrant')
conf = YAML.load_file('system/host_vars/gislab_vagrant')
conf.each do |key, value|
if not value.nil?
CONFIG[key] = value
end
end
end
# Vagrant box
BOX = "%s-canonical" % [CONFIG["GISLAB_UBUNTU_VERSION"]]
BOX_URL = "https://cloud-images.ubuntu.com/%s/current/%s-server-cloudimg-amd64-vagrant.box" % [CONFIG["GISLAB_UBUNTU_VERSION"], CONFIG["GISLAB_UBUNTU_VERSION"]]
# GIS.lab configuration for Vagrant
# super user password
if CONFIG.has_key? 'GISLAB_ADMIN_PASSWORD'
CONFIG_VAGRANT["GISLAB_ADMIN_PASSWORD"] = CONFIG['GISLAB_ADMIN_PASSWORD']
end
# Vagrant provisioning
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# fix for https://github.com/ansible/ansible/issues/8644
ENV['PYTHONIOENCODING'] = "utf-8"
config.vm.box = BOX
config.vm.box_url = BOX_URL
config.vm.synced_folder '.', '/vagrant', disabled: true
config.ssh.forward_agent = true
config.disksize.size = '40GB'
# provisioning
config.vm.define :gislab_vagrant_jammy do |server|
server.vm.network "public_network", ip: CONFIG['GISLAB_NETWORK'] + ".5"
# VirtualBox configuration
server.vm.provider "virtualbox" do |vb, override|
# always set client virtualbox support
CONFIG['GISLAB_CLIENT_VIRTUALBOX_SUPPORT'] = 'yes'
# use unique name
vb.name = 'gislab-vagrant-' + CONFIG["GISLAB_UBUNTU_VERSION"]
vb.customize ["modifyvm", :id, "--memory", CONFIG['GISLAB_SERVER_MEMORY']]
vb.customize ["modifyvm", :id, "--cpus", CONFIG['GISLAB_SERVER_CPUS']]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
if CONFIG['GISLAB_SERVER_GUI_CONSOLE'] == true
vb.gui = true
end
end
# installation
server.vm.provision "install", type: "ansible" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.playbook = "system/gislab.yml"
# verbosity
if CONFIG['GISLAB_DEBUG_INSTALL'] == true
ansible.verbose = "vv"
end
# ansible variables
ansible.extra_vars = CONFIG_VAGRANT
end
# tests
if CONFIG['GISLAB_TESTS_ENABLE'] == true
server.vm.provision "test", type: "ansible" do |ansible|
ansible.playbook = "system/test.yml"
# verbosity
ansible.verbose = "vv"
# ansible variables
ansible.extra_vars = CONFIG_VAGRANT
end
end
end
end