This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Vagrantfile
181 lines (157 loc) · 6.05 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# -*- mode: ruby -*-
# vi: set ft=ruby :
def parse_config(
config_file=File.expand_path(File.join(File.dirname(__FILE__), 'config.yml'))
)
require 'yaml'
config = {
'sites' => "sites",
'webroot_subdir' => "",
'databases' => "databases",
'memory' => '2048',
'cpus' => '1',
'use_nfs' => true,
'with_gui' => false,
'ip' => "192.168.50.4",
'box_name' => 'Parrot-Trusty',
'varnish_enabled' => false,
'local_user_uid' => Process.uid,
'local_user_gid' => Process.gid,
'forward_solr' => true,
'forward_mysql' => true,
'forward_varnish' => true,
'forward_apache' => true,
'forward_https' => true,
'forward_dovecot' => true,
'solr_port' => 8983,
'mysql_port' => 3306,
'varnish_port' => 8181,
'apache_port' => 8080,
'https_port' => 1443,
'dovecot_port' => 1143,
'drush_version' => 'drush/drush',
}
if File.exists?(config_file)
overrides = YAML.load_file(config_file)
config.merge!(overrides)
end
config
end
Vagrant.require_version ">= 1.3.0"
Vagrant.configure('2') do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
custom_config = parse_config
# Note the backticks on this next line.
architecture = `uname -m`.strip
if ((architecture == 'x86_64') || (architecture == 'ia64'))
bits = 64
else
bits = 32
end
################# VMWare Fusion ########################
config.vm.provider "vmware_fusion" do |box, override|
if (bits == 32)
override.vm.box_url = "https://atlas.hashicorp.com/puphpet/boxes/ubuntu1404-x32"
override.vm.box = "puphpet/ubuntu1404-x32"
override.vm.box_version = "20151128"
else
override.vm.box_url = "https://atlas.hashicorp.com/puphpet/boxes/ubuntu1404-x64"
override.vm.box = "puphpet/ubuntu1404-x64"
override.vm.box_version = "20151128"
end
box.vmx["memsize"] = custom_config['memory']
box.vmx["numvcpus"] = custom_config['cpus']
# Boot with a GUI so you can see the screen. (Default is headless)
box.gui = custom_config['with_gui']
end
################# Parallels ########################
config.vm.provider "parallels" do |box, override|
override.vm.box_url = "https://atlas.hashicorp.com/puphpet/boxes/ubuntu1404-x64"
box.memory = custom_config['memory']
box.cpus = custom_config['cpus']
box.name = custom_config['box_name']
end
################# Virtual Box ########################
config.vm.provider :virtualbox do |box, override|
if (bits == 32)
override.vm.box = "ubuntu/trusty32"
else
override.vm.box = "ubuntu/trusty64"
end
# Specify number of cpus/cores to use
box.customize ["modifyvm", :id, "--cpus", custom_config['cpus']]
box.customize ['modifyvm', :id, '--memory', custom_config['memory']]
box.name = custom_config['box_name']
# Boot with a GUI so you can see the screen. (Default is headless)
box.gui = custom_config['with_gui']
end
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
config.vm.network :private_network, ip: custom_config['ip']
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
# Solr
if custom_config['forward_solr']
config.vm.network :forwarded_port, :guest => 8983, :host => custom_config['solr_port']
end
# MySQL
if custom_config['forward_mysql']
config.vm.network :forwarded_port, :guest => 3306, :host => custom_config['mysql_port']
end
# Varnish
if custom_config['forward_varnish']
config.vm.network :forwarded_port, :guest => 80, :host => custom_config['varnish_port']
end
# Apache
if custom_config['forward_apache']
config.vm.network :forwarded_port, :guest => 8080, :host => custom_config['apache_port']
end
# HTTPS
if custom_config['forward_https']
config.vm.network :forwarded_port, :guest => 443, :host => custom_config['https_port']
end
# Dovecot - IMAP
if custom_config['forward_dovecot']
config.vm.network :forwarded_port, :guest => 143, :host => custom_config['dovecot_port']
end
# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
config.vm.synced_folder "parrot-config", "/vagrant_parrot_config"
if custom_config['use_nfs']
config.vm.synced_folder custom_config['sites'], "/vagrant_sites", :nfs => true
else
config.vm.synced_folder custom_config['sites'], "/vagrant_sites"
end
config.vm.synced_folder custom_config['databases'], "/vagrant_databases"
# Use Vagrant Cachier
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# Enable ssh key forwarding
config.ssh.forward_agent = true
# A quick bootstrap to get Puppet installed.
config.vm.provision "shell", path: "scripts/bootstrap.sh"
# And now the meat.
config.vm.provision :puppet do |puppet|
#puppet.options = "--verbose --debug"
puppet.manifests_path = "manifests"
puppet.manifest_file = "parrot.pp"
puppet.module_path = ["forge-modules", "modules"]
# Add a custom fact so we can reliably hit the host IP from the guest.
puppet.facter = {
"parrot_drush_version" => custom_config['drush_version'],
"vagrant_guest_ip" => custom_config['ip'],
"parrot_php_version" => custom_config['php_version'],
"parrot_mysql_version" => custom_config['mysql_version'],
"apache_vhost_webroot_subdir" => custom_config['webroot_subdir'],
"parrot_varnish_enabled" => custom_config['varnish_enabled'],
"vagrant_host_user_uid" => custom_config['local_user_uid'],
"vagrant_host_user_gid" => custom_config['local_user_gid'],
}
end
end