Permalink
Browse files

Vagrant provisioning

  • Loading branch information...
alfredo committed Jun 21, 2012
1 parent 7f08053 commit f87da4e8698250eef91b3596029f66348d5f5748
View
@@ -23,3 +23,5 @@ media/ignite/img/uploads*
whoosh_index/
#*
.#*
+.vagrant
+vagrantconfig_local.yaml
View
@@ -1,7 +1,11 @@
-mozilla-ignite
-==============
+===============
+Mozilla Ignite
+===============
+
+mozilla-ignite is a challenge and participation platform that's being built on-top of the [betafarm architecture]: https://github.com/mozilla/betafarm
+
+The Project structure is based on Mozilla Playdoh http://playdoh.readthedocs.org/en/latest/index.html
-mozilla-ignite is a challenge and participation platform that's being built on-top of the [betafarm architecture]: https://github.com/mozilla/betafarm
Contributing
------------
@@ -11,8 +15,86 @@ Patches are welcome! Feel free to fork and contribute to this project on
[gh-betafarm]: https://github.com/rossbruniges/mozilla-ignite
+
Installation
-------------
+============
+
+The recommended setup is using [vagrant](http://vagrantup.com/) and [virtual box](https://www.virtualbox.org/wiki/Downloads)
+
+
+Getting the source code
+-----------------------
+
+Clone the repository and its dependencies:
+
+ git clone --recursive git@github.com:rossbruniges/mozilla-ignite.git
+
+This will take a few minutes.
+
+This will keep the code living in your filesystem but the application running inside a VM.
+
+Once you've installed vagrant, from the root of the repository copy the local vagrant settings.
+
+ cp vagrantconfig_local.yaml-dist vagrantconfig_local.yaml
+
+Edit ``vagrantconfig_local.yaml`` if you want to change any of the defaults.
+
+If you are on an NFS capable OS I recommend that you change ``nfs`` to ``true``.
+
+VirtualBox has know issues sharing files natively, more about this: http://vagrantup.com/docs/nfs.html
+
+
+Update the local settings file
+==============================
+
+From the root of the repository copy the local python settings.
+
+ cp settings_local.py-dist settings_local.py
+
+Amend ``popcorn_gallery/settings/local.py`` adding your details:
+
+- ADMINS: Add an email address and a name.
+- SECRET_KEY: This can be anything.
+- HMAC_KEYS: Uncomment or add your own key inside it.
+
+
+Start the VM
+============
+
+Now we are ready to provision the machine run.
+
+ vagrant up
+
+This will take a few minutes, so go on and reward yourself with a nice cup of tea!
+
+
+
+Add a host alias
+================
+
+This is done so you can access the application via: http://local.mozillaignite.org and perform the browserid assertion.
+
+If you are on OSX or *NIX add an alias for the site by running the following command in your local machine:
+
+ echo "33.33.33.12 local.mozillaignite.org" | sudo tee -a /etc/hosts
+
+Or if you prefer a GUI try http://code.google.com/p/gmask/
+
+Now the application should be available at:
+
+ http://local.mozillaignite.org
+
+
+Creating a superuser
+====================
+
+From inside the VM run:
+
+ python manage.py createsuperuser
+
+
+Setup the application
+---------------------
You've need git and pip installed on the machine you want to install it on
@@ -33,6 +115,8 @@ You've need git and pip installed on the machine you want to install it on
9. Compress your assets
* ./manage.py compress_assets
+
+
License
-------
This software is licensed under the [New BSD License][BSD]. For more
View
@@ -0,0 +1,56 @@
+require "yaml"
+
+# Load up our vagrant config files -- vagrantconfig.yaml first
+_config = YAML.load(File.open(File.join(File.dirname(__FILE__),
+ "vagrantconfig.yaml"), File::RDONLY).read)
+
+# Local-specific/not-git-managed config -- vagrantconfig_local.yaml
+begin
+ _config.merge!(YAML.load(File.open(File.join(File.dirname(__FILE__),
+ "vagrantconfig_local.yaml"), File::RDONLY).read))
+rescue Errno::ENOENT # No vagrantconfig_local.yaml found -- that's OK; just
+ # use the defaults.
+end
+
+CONF = _config
+MOUNT_POINT = '/home/vagrant/mozilla-ignite'
+PROJECT_NAME = 'mozilla-ignite'
+
+Vagrant::Config.run do |config|
+ config.vm.box = "lucid32"
+ config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
+
+ if CONF['gui'] == true
+ config.vm.boot_mode = :gui
+ end
+ # Increase vagrant's patience during hang-y CentOS bootup
+ # see: https://github.com/jedi4ever/veewee/issues/14
+ config.ssh.max_tries = 50
+ config.ssh.timeout = 300
+
+ # nfs needs to be explicitly enabled to run.
+ if CONF['nfs'] == false or RUBY_PLATFORM =~ /mswin(32|64)/
+ config.vm.share_folder("v-root", MOUNT_POINT, ".")
+ else
+ config.vm.share_folder("v-root", MOUNT_POINT, ".", :nfs => true)
+ end
+
+ # Add to /etc/hosts: 33.33.33.12 local.mozillaignite.org
+ config.vm.network :hostonly, "33.33.33.12"
+
+ config.vm.provision :puppet do |puppet|
+ puppet.manifests_path = "puppet/manifests"
+ puppet.module_path = "puppet/modules"
+ puppet.manifest_file = "vagrant.pp"
+ if CONF['debug'] == true
+ puppet.options = "--verbose --debug"
+ end
+ puppet.facter = [
+ ['username', CONF['username']],
+ ['password', CONF['password']],
+ ['project_path', MOUNT_POINT],
+ ['project_name', PROJECT_NAME],
+ ['server_name', CONF['server_name']],
+ ]
+ end
+end
@@ -0,0 +1,23 @@
+# Generate a self-signed certificate to match production.
+class certificates ($server_name) {
+
+ $certs_path = "/etc/ssl/local"
+
+ package { "openssl":
+ ensure => installed;
+ }
+
+ file { $certs_path:
+ ensure => "directory",
+ owner => "root",
+ group => "root",
+ mode => 600,
+ require => Package[openssl];
+ }
+
+ exec { "openssl-generate-cert":
+ command => "openssl req -new -x509 -days 365 -nodes -out $certs_path/$server_name.pem -keyout $certs_path/$server_name.key -subj '/C=US/ST=CA/L=Mountain View/O=Mozilla Foundation/OU=Webdev/CN=$server_name'",
+ creates => ["/etc/ssl/local/$server_name.key", "/etc/ssl/local/$server_name.pem"],
+ require => File[$certs_path];
+ }
+}
@@ -0,0 +1,23 @@
+# stage {"pre": before => Stage["main"]} class {'apt': stage => 'pre'}
+
+# Commands to run before all others in puppet.
+class init {
+ group { "puppet":
+ ensure => "present",
+ }
+
+ case $operatingsystem {
+ ubuntu: {
+ exec { "update_apt":
+ command => "sudo apt-get update",
+ }
+
+ package { ["python-software-properties", "build-essential"]:
+ ensure => present,
+ require => [
+ Exec['update_apt'],
+ ];
+ }
+ }
+ }
+}
@@ -0,0 +1,14 @@
+# We use memcached in production, so we _should_ use it while
+# we develop as well. That said, playdoh shouldn't *rely* on it
+# entirely; it should work with any non-null cache store in Django.
+class memcached {
+ package { "memcached":
+ ensure => installed;
+ }
+
+ service { "memcached":
+ ensure => running,
+ enable => true,
+ require => Package['memcached'];
+ }
+}
@@ -0,0 +1,37 @@
+# Project specific setup
+# TODO: Make this rely on things that are not straight-up exec.
+class playdoh ($project_path, $project_name, $password){
+
+ $settings_file = "$project_path/settings_local.py"
+
+ file { $settings_file:
+ ensure => file,
+ source => "$project_path/settings_local.py-dist",
+ replace => false;
+ }
+
+ exec { "create_mysql_database":
+ command => "mysql -uroot -p$password -B -e'CREATE DATABASE `$project_name` CHARACTER SET utf8;'",
+ unless => "mysql -uroot -p$password -B --skip-column-names -e 'show databases' | /bin/grep '$project_name'",
+ require => File[$settings_file]
+ }
+
+ exec { "grant_mysql_database":
+ command => "mysql -uroot -p$password -B -e \"GRANT ALL PRIVILEGES ON *.* TO '$project_name'@'localhost' IDENTIFIED BY '$project_name'\"",
+ unless => "mysql -uroot -p$password -B --skip-column-names mysql -e 'select user from user' | grep '$project_name'",
+ require => Exec["create_mysql_database"];
+ }
+
+ exec { "syncdb":
+ cwd => "$project_path",
+ command => "python manage.py syncdb --noinput",
+ require => Exec["grant_mysql_database"];
+ }
+
+ exec { "migrations":
+ cwd => "$project_path",
+ command => "python manage.py migrate",
+ require => Exec["syncdb"];
+ }
+
+}
@@ -0,0 +1,33 @@
+# Install python and compiled modules for project
+class python ($project_path){
+ case $operatingsystem {
+ ubuntu: {
+ $packages = ["python2.6-dev",
+ "python2.6",
+ "python-imaging",
+ "python-wsgi-intercept",
+ "python-pip",
+ "python-lxml"]
+ package { $packages:
+ ensure => installed,
+ }
+ exec { "virtualenvwrapper":
+ command => "pip install virtualenv virtualenvwrapper",
+ require => Package[$packages],
+ }
+
+ exec { "pip-install-compiled":
+ cwd => "$project_path/requirements",
+ command => "pip install -r $project_path/requirements/compiled.txt",
+ require => Package[$packages],
+ }
+
+ exec { "pip-install-development":
+ cwd => "$project_path/requirements",
+ command => "pip install -r $project_path/requirements/dev.txt",
+ require => Exec["pip-install-compiled"],
+ }
+
+ }
+ }
+}
@@ -0,0 +1,10 @@
+class versioning {
+ case $operatingsystem {
+ ubuntu: {
+ $packages = ["git-core", "subversion", "mercurial"]
+ package { $packages:
+ ensure => installed;
+ }
+ }
+ }
+}
@@ -0,0 +1,57 @@
+#
+# Playdoh puppet magic for dev boxes
+#
+import "classes/*.pp"
+
+$PROJ_DIR = $project_path
+
+# You can make these less generic if you like, but these are box-specific
+# so it's not required.
+$DB_NAME = $project_name
+$DB_PASS = $password
+
+Exec {
+ path => "/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin",
+}
+
+class dev {
+ class {
+ init: ;
+ memcached: ;
+ versioning: ;
+ }
+ class { "mysql":
+ require => Class[init],
+ password => $password;
+ }
+ class { "python":
+ require => Class[mysql],
+ project_path => $project_path;
+ }
+ class { "certificates":
+ require => Class[python],
+ server_name => $server_name;
+ }
+ class { "apache":
+ require => Class[certificates],
+ server_name => $server_name,
+ project_path => $project_path;
+ }
+ class { "nginx":
+ require => Class[apache],
+ server_name => $server_name,
+ project_path => $project_path;
+ }
+ class { "playdoh":
+ project_path => $project_path,
+ project_name => $project_name,
+ password => $password,
+ require => Class[nginx];
+ }
+ class { "custom":
+ project_path => $project_path,
+ project_name => $project_name;
+ }
+}
+
+include dev
Oops, something went wrong.

0 comments on commit f87da4e

Please sign in to comment.