-
Notifications
You must be signed in to change notification settings - Fork 11
/
Vagrantfile
135 lines (109 loc) · 4.18 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
#################################
# Base box and vm configuration #
#################################
# Set the vm's host name. Consider setting this to the name of your project.
config.vm.host_name = "drupal"
# Name of base box to be used
config.vm.box = "ubuntu-10.04.4-server-amd64"
# Url of base box in case vagrant needs to download it
config.vm.box_url = "http://dl.dropbox.com/u/56687100/ubuntu-10.04.4-server-amd64.box"
# Set the memory size
config.vm.customize ["modifyvm", :id, "--memory", "1024"]
# VirtualBox performance improvements
config.vm.customize ["modifyvm", :id, "--nictype1", "virtio"]
config.vm.customize ["modifyvm", :id, "--nictype2", "virtio"]
config.vm.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "off"]
#################################
# Networking #
#################################
# Use port-forwarding. Web site will be at http://localhost:4567
config.vm.forward_port(80, 4567, :auto => true)
# Use host-only networking. Required for nfs shared folder.
# Web site will be at http://<config.vm.host_name>.local
#
# config.vm.network :hostonly, "172.21.21.21"
#################################
# Shared Folders #
#################################
# Path to our shared folder for project files.
srv_path = File.expand_path(File.dirname(__FILE__)) + "/srv"
# Use vboxfs for shared folder.
config.vm.share_folder("srv", "/srv", srv_path, :owner => "vagrant", :group => "www-data", :create => true)
# Use nfs for shared folder. Just un-comment this line and turn on static
# host-only networking. vboxfs is known to have performance issues
# on non-windows hosts. http://vagrantup.com/docs/nfs.html
#
# config.vm.share_folder("srv", "/srv", srv_path, :nfs => true, :create => true);
#################################
# Librarian #
#################################
# Only run if "up" was called
if ARGV.first == "up"
# Path to our cookbooks folder
cookbooks_path = File.expand_path(File.dirname(__FILE__)) + "/cookbooks"
# Run librarian if cookbooks folder does not exist or is empty
if !Dir::exists?(cookbooks_path) || (Dir.entries(cookbooks_path).size < 3)
puts 'Running "librarian-chef install"...'
puts `librarian-chef install`
end
end
#################################
# Provisioners #
#################################
# Provision a new vm using chef-solo
config.vm.provision :chef_solo do |chef|
# To turn on chef debug output, run "CHEF_LOG=1 vagrant up" from command line
chef.log_level = :debug if !(ENV['CHEF_LOG']).nil?
# The librarian gem controls the "cookbook" folder, do not touch it. If you
# need to create site-specific cookbooks, place them in "site-cookbooks".
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
# Default top-level chef recipes
chef.add_recipe "xforty"
chef.add_recipe "squid"
chef.add_recipe "drupal"
chef.add_recipe "initdb"
# Specify custom JSON node attributes
chef.json.merge!(
'mysql' => {
'server_root_password' => 'root'
},
'initdb' => {
'mysql' => {
'connection' => {
'username' => 'root',
'password' => 'root',
'host' => 'localhost'
},
'databases' => {
'drupal' => {
'action' => 'create'
}
},
'users' => {
'username' => {
'action' => 'grant',
'database_name' => 'drupal',
'host' => 'localhost',
'password' => 'password'
}
}
}
},
'apache' => {
'prefork' => {
'startservers' => 4,
'minspareservers' => 4,
'maxspareservers' => 4,
'serverlimit' => 4,
'maxclients' => 4,
'maxrequestsperchild' => 1000
}
}
)
end
# Run any necessary shell commands on the vm
config.vm.provision :shell, :path => "bin/postvagrant.sh"
end