4 # This file is for use by Vagrant (http://www.vagrantup.com/).
5 # It will establish a debian-based (Ubuntu) virtual machine for development.
7 # The virtual machine environment attempts to match the production environment
8 # as closely as possible.
10 # This file was generated by `vagrant up` and consequently modified.
12 # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
13 VAGRANTFILE_API_VERSION = "2"
15 # Copy the vagrant SSH key into the VM so vagrant can SSH to localhost within
16 # the VM. Continued in the shell script below.
17 # http://serverfault.com/questions/491343/how-can-i-move-my-deploy-key-into-vagrant#comment549259_491345
18 git_ssh_key = File.read(ENV['HOME'] + '/.vagrant.d/insecure_private_key');
20 # build a shell script that installs prereqs, configures the database, sets up
21 # the user/group associations, pulls in the code from the host machine, sets up
22 # some external dependency configs, and then runs fabric.
23 shellscript = <<SCRIPT
24 cat >>/home/vagrant/.ssh/insecure_private_key <<EOF
27 chown vagrant:vagrant /home/vagrant/.ssh/insecure_private_key
28 chmod 600 /home/vagrant/.ssh/insecure_private_key
29 cat >>/home/vagrant/.ssh/config <<EOF
32 IdentityFile ~/.ssh/insecure_private_key
36 IdentityFile ~/.ssh/insecure_private_key
38 chmod 644 /home/vagrant/.ssh/config
42 apt-get install -y python-pip postgresql python-virtualenv virtualenvwrapper \
43 git nginx postgresql-server-dev-9.1 libxslt1-dev \
44 libxml2-dev libmemcached-dev python-dev rabbitmq-server \
47 echo "CREATE USER vagrant WITH CREATEROLE LOGIN; CREATE DATABASE karmaworld OWNER vagrant;" | su postgres -c "psql"
49 mkdir -m 775 -p /var/www
50 chown -R :www-data /var/www
51 usermod -a -G www-data vagrant
53 su vagrant -c "git clone /vagrant karmaworld"
55 SECRETPATH="karmaworld/karmaworld/secret"
56 CFILE="$SECRETPATH/db_settings.py"
60 # Copyright (C) 2012 FinalsClub Foundation
62 DO NOT check this file into source control.
64 PROD_DB_NAME = 'karmaworld'
65 PROD_DB_USERNAME = 'vagrant'
68 cp $SECRETPATH/filepicker.py.example $SECRETPATH/filepicker.py
69 cp $SECRETPATH/static_s3.py.example $SECRETPATH/static_s3.py
70 chown vagrant:vagrant $SECRETPATH/*.py
72 cat > /etc/nginx/sites-available/karmaworld <<CONFIG
75 # don't do virtual hosting, handle all requests regardless of header
77 client_max_body_size 20M;
80 # pass traffic through to gunicorn
81 proxy_pass http://127.0.0.1:8000;
85 rm /etc/nginx/sites-enabled/default
86 ln -s /etc/nginx/sites-available/karmaworld /etc/nginx/sites-enabled/karmaworld
87 sudo service nginx restart
89 cp karmaworld/confs/prod/supervisor /etc/init.d
90 chmod 755 /etc/init.d/supervisor
91 update-rc.d supervisor defaults
94 su vagrant -c "cd karmaworld; fab -H 127.0.0.1 first_deploy"
98 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
99 # All Vagrant configuration is done here. The most common configuration
100 # options are documented and commented below. For a complete reference,
101 # please see the online documentation at vagrantup.com.
103 # Every Vagrant virtual environment requires a box to build off of.
104 config.vm.box = "Official Ubuntu 12.04 daily Cloud Image i386"
105 #config.vm.box = "Official Ubuntu 12.04 daily Cloud Image amd64"
106 #config.vm.box = "Official Ubuntu 12.10 daily Cloud Image i386"
107 #config.vm.box = "Official Ubuntu 12.10 daily Cloud Image amd64"
108 #config.vm.box = "Official Ubuntu 13.04 daily Cloud Image i386"
109 #config.vm.box = "Official Ubuntu 13.04 daily Cloud Image amd64"
110 #config.vm.box = "Official Ubuntu 13.10 daily Cloud Image i386"
111 #config.vm.box = "Official Ubuntu 13.10 daily Cloud Image amd64"
113 # The url from where the 'config.vm.box' box will be fetched if it
114 # doesn't already exist on the user's system.
115 config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-i386-vagrant-disk1.box"
116 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
117 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-i386-vagrant-disk1.box"
118 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-amd64-vagrant-disk1.box"
119 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-i386-vagrant-disk1.box"
120 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box"
121 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-i386-vagrant-disk1.box"
122 #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
124 # Create a forwarded port mapping which allows access to a specific port
125 # within the machine from a port on the host machine. In the example below,
126 # accessing "localhost:8080" will access port 80 on the guest machine.
127 # config.vm.network :forwarded_port, guest: 80, host: 8080
129 # OM (sanskrit) KW (KarmaWorld) on a phone: 66 59
130 config.vm.network :forwarded_port, guest: 80, host: 6659, auto_correct: true
132 # Create a private network, which allows host-only access to the machine
133 # using a specific IP.
134 #config.vm.network :private_network, ip: "192.168.66.59"
136 # Create a public network, which generally matched to bridged network.
137 # Bridged networks make the machine appear as another physical device on
139 # Used to directly access the internet for downloading updates and so forth.
140 config.vm.network :public_network
142 # If true, then any SSH connections made will enable agent forwarding.
143 # Default value: false
144 # config.ssh.forward_agent = true
146 # Share an additional folder to the guest VM. The first argument is
147 # the path on the host to the actual folder. The second argument is
148 # the path on the guest to mount the folder. And the optional third
149 # argument is a set of non-required options.
150 # config.vm.synced_folder "../data", "/vagrant_data"
153 config.vm.provision "shell", inline: shellscript
155 # Provider-specific configuration so you can fine-tune various
156 # backing providers for Vagrant. These expose provider-specific options.
157 # Example for VirtualBox:
159 # config.vm.provider :virtualbox do |vb|
160 # # Don't boot with headless mode
163 # # Use VBoxManage to customize the VM. For example to change memory:
164 # vb.customize ["modifyvm", :id, "--memory", "1024"]
167 # View the documentation for the provider you're using for more
168 # information on available options.
170 # Enable provisioning with Puppet stand alone. Puppet manifests
171 # are contained in a directory path relative to this Vagrantfile.
172 # You will need to create the manifests directory and a manifest in
173 # the file base.pp in the manifests_path directory.
175 # An example Puppet manifest to provision the message of the day:
177 # # group { "puppet":
178 # # ensure => "present",
181 # # File { owner => 0, group => 0, mode => 0644 }
183 # # file { '/etc/motd':
184 # # content => "Welcome to your Vagrant-built virtual machine!
185 # # Managed by Puppet.\n"
188 # config.vm.provision :puppet do |puppet|
189 # puppet.manifests_path = "manifests"
190 # puppet.manifest_file = "site.pp"
193 # Enable provisioning with chef solo, specifying a cookbooks path, roles
194 # path, and data_bags path (all relative to this Vagrantfile), and adding
195 # some recipes and/or roles.
197 # config.vm.provision :chef_solo do |chef|
198 # chef.cookbooks_path = "../my-recipes/cookbooks"
199 # chef.roles_path = "../my-recipes/roles"
200 # chef.data_bags_path = "../my-recipes/data_bags"
201 # chef.add_recipe "mysql"
202 # chef.add_role "web"
204 # # You may also specify custom JSON attributes:
205 # chef.json = { :mysql_password => "foo" }
208 # Enable provisioning with chef server, specifying the chef server URL,
209 # and the path to the validation key (relative to this Vagrantfile).
211 # The Opscode Platform uses HTTPS. Substitute your organization for
212 # ORGNAME in the URL and validation key.
214 # If you have your own Chef Server, use the appropriate URL, which may be
215 # HTTP instead of HTTPS depending on your configuration. Also change the
216 # validation key to validation.pem.
218 # config.vm.provision :chef_client do |chef|
219 # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
220 # chef.validation_key_path = "ORGNAME-validator.pem"
223 # If you're using the Opscode platform, your validator client is
224 # ORGNAME-validator, replacing ORGNAME with your organization name.
226 # If you have your own Chef Server, the default validation client name is
227 # chef-validator, unless you changed the configuration.
229 # chef.validation_client_name = "ORGNAME-validator"