-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
145 lines (132 loc) · 5.14 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
require 'yaml'
def chef_cloud_attributes(instance_type)
case instance_type
when 'vagrant'
@app[:url] = 'mtwa.local'
end
return {
:ec2 => false,
:lsb => { :code_name => 'lucid' },
:bootstrap => {:chef => {:client_version => '0.9.12'}},
:fqdn => @app[:url],
:hostname => @app[:name],
:chef => { :roles => ['vagrant', 'app', 'database'],
:log_level => :debug
},
:ubuntu => { :servers => [
{:ip => '127.0.0.1', :fqdn => @app[:url], :alias => @app[:name]},
{:ip => '127.0.1.1', :fqdn => 'vagrantup.com', :alias => 'vagrantup'},
{:ip => '127.0.0.1', :fqdn => "database.#{@app[:name]}.internal", :alias => 'database'},
{:ip => '127.0.0.1', :fqdn => "app.#{@app[:name]}.internal", :alias => 'app'}
],
:database => { :fqdn => "database.#{@app[:name]}.internal" },
:mysql => true,
:users => { :accounts => {} }
},
:app => { :root_dir => "/var/www/apps/#{@app[:name]}", :app_name => @app[:name], :url => @app[:url] },
:server => { :name => "#{@app[:name]}_#{@rails_env}" },
:authorization => { :sudo => { :groups => ['admin'], :users => ['vagrant'] } },
:ruby => { :version => 'ree' },
:apache => {
:vhost_port => @app[:server_port],
:vhosts => [
{ :server_name => @app[:url],
:server_aliases => '',
:docroot => "/var/www/apps/#{@app[:name]}/public",
:name => @app[:url]
}
],
:server_name => @app[:url],
:web_dir => '/var/www',
:docroot => "/var/www/apps/#{@app[:name]}/public",
:name => @app[:name],
:enable_mods => ["rewrite", "deflate", "expires"],
:prefork => {
:startservers => 128,
:minspareservers => 32,
:maxspareservers => 128
}
},
:rails => {
:environment => @rails_env,
:db_adapter => 'mysql',
:version => '3.0.4',
:using_shared => false,
:app_root_dir => "/var/www/apps/#{@app[:name]}",
:db_directory => "/var/www/apps/#{@app[:name]}"
},
:mysql => {
:bind_address => "database.#{@app[:name]}.internal",
:database_name => "#{@app[:name]}_#{@rails_env}",
:server_root_password => '',
:server_repl_password => '',
:server_debian_password => '',
:tunable => {
:query_cache_size => '40M',
:tmp_table_size => '100M',
:max_heap_table_size => '100M',
:innodb_buffer_pool_size => '1GB'
}
},
:passenger_enterprise => {
:version => '3.0.2',
:pool_idle_time => 100000,
:max_requests => 10000,
:max_pool_size => 10,
:packages => %w(apache2-threaded-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev) # added libcurl4-openssl-dev
},
:ruby_enterprise => {
:version => '1.8.7-2011.01',
:url => 'http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.01' # do not include extensions
},
:git => {
:version => '1.7.4.1',
:packages => %w(build-dep git-core tcllib), # added tcllib
:install_from_source => false
}
}
end
Vagrant::Config.run do |config|
@app = {}
@app[:name] = 'mtwa'
@app[:sever_port] = 80
@rails_env = 'development'
# 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.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid64"
# Assign this VM to a host only network IP, allowing you to access it
# via the IP.
config.vm.network "33.33.33.04"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
config.vm.forward_port "http", 80, 8080
# 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.share_folder("app-data", "/var/www/apps/#{@app[:name]}", ".")
config.vm.share_folder("home-dir", "/home/vagrant/home", "..")
config.vm.share_folder("bundler-dir", "/home/vagrant/.bundler", "tmp/vagrant_bundler")
# Enable provisioning with chef solo, specifying a cookbooks path (relative
# to this Vagrantfile), and adding some recipes and/or roles.
#
config.vm.provision :chef_solo do |chef|
chef.log_level = :debug
chef.cookbooks_path = "vendor/cookbooks"
recipes = ["apt",
"ubuntu",
"openssl",
"mysql::server",
"apache2",
"passenger_enterprise::apache2",
'git',
'rails'] # "rubygems"
recipes.each do |recipe|
chef.add_recipe(recipe)
end
# config.chef.add_role "web"
# We need to pass our attributes for chef to set up properly
chef.json.merge!( chef_cloud_attributes('vagrant') )
end
end