Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add puppet to playdoh

Yo dawg I heard you liked developing so I developed a development VM.
  • Loading branch information...
commit 17137d2a942e7f6f8e27c6a1322e47bc9380296c 1 parent de9310c
Matthew Riley MacPherson tofumatt authored
43 Vagrantfile
... ... @@ -0,0 +1,43 @@
  1 +require "yaml"
  2 +
  3 +# Load up our vagrant config files -- vagrantconfig.yaml first
  4 +_config = YAML.load(File.open(File.join(File.dirname(__FILE__),
  5 + "vagrantconfig.yaml"), File::RDONLY).read)
  6 +
  7 +# Local-specific/not-git-managed config -- vagrantconfig_local.yaml
  8 +begin
  9 + _config.merge!(YAML.load(File.open(File.join(File.dirname(__FILE__),
  10 + "vagrantconfig_local.yaml"), File::RDONLY).read))
  11 +rescue Errno::ENOENT # No vagrantconfig_local.yaml found -- that's OK; just
  12 + # use the defaults.
  13 +end
  14 +
  15 +CONF = _config
  16 +MOUNT_POINT = '/home/vagrant/project'
  17 +
  18 +Vagrant::Config.run do |config|
  19 + config.vm.box = "lucid32"
  20 + config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
  21 +
  22 + config.vm.forward_port("web", 8000, 8000)
  23 +
  24 + # Increase vagrant's patience during hang-y CentOS bootup
  25 + # see: https://github.com/jedi4ever/veewee/issues/14
  26 + config.ssh.max_tries = 50
  27 + config.ssh.timeout = 300
  28 +
  29 + # nfs needs to be explicitly enabled to run.
  30 + if CONF['nfs'] == false or RUBY_PLATFORM =~ /mswin(32|64)/
  31 + config.vm.share_folder("v-root", MOUNT_POINT, ".")
  32 + else
  33 + config.vm.share_folder("v-root", MOUNT_POINT, ".", :nfs => true)
  34 + end
  35 +
  36 + # Add to /etc/hosts: 33.33.33.24 dev.playdoh.org
  37 + config.vm.network "33.33.33.24"
  38 +
  39 + config.vm.provision :puppet do |puppet|
  40 + puppet.manifests_path = "puppet/manifests"
  41 + puppet.manifest_file = "vagrant.pp"
  42 + end
  43 +end
30 puppet/files/etc/httpd/conf.d/playdoh.conf
... ... @@ -0,0 +1,30 @@
  1 +# HACK: Make the server reload after every hit to refresh django code
  2 +MaxRequestsPerChild 1
  3 +
  4 +WSGISocketPrefix /var/run/wsgi
  5 +
  6 +<VirtualHost *:443 *:80>
  7 + ServerName dev.playdoh.org
  8 +
  9 + DirectoryIndex index.php index.html
  10 + Options -Indexes
  11 +
  12 + RewriteEngine On
  13 +
  14 + DocumentRoot "/var/www/html/"
  15 +
  16 + Alias /media/ "/home/vagrant/project/media/"
  17 + Alias /admin-media/ "/home/vagrant/project/vendor/src/django/django/contrib/admin/media/"
  18 +
  19 + WSGIDaemonProcess playdoh processes=1 threads=1 maximum-requests=1
  20 + WSGIProcessGroup playdoh
  21 +
  22 + WSGIScriptAlias / "/home/vagrant/project/wsgi/playdoh.wsgi"
  23 +
  24 + <Proxy *>
  25 + AddDefaultCharset off
  26 + Order deny,allow
  27 + Deny from all
  28 + Allow from all
  29 + </Proxy>
  30 +</VirtualHost>
53 puppet/manifests/classes/apache.pp
... ... @@ -0,0 +1,53 @@
  1 +# Red Hat, CentOS, and Fedora think Apache is the only web server
  2 +# ever, so we have to use a different package on CentOS than Ubuntu.
  3 +class apache {
  4 + case $operatingsystem {
  5 + centos: {
  6 + package { "httpd-devel":
  7 + ensure => present,
  8 + before => File['/etc/httpd/conf.d/playdoh.conf'];
  9 + }
  10 +
  11 + file { "/etc/httpd/conf.d/playdoh.conf":
  12 + source => "$PROJ_DIR/puppet/files/etc/httpd/conf.d/playdoh.conf",
  13 + owner => "root", group => "root", mode => 0644,
  14 + require => [
  15 + Package['httpd-devel']
  16 + ];
  17 + }
  18 +
  19 + service { "httpd":
  20 + ensure => running,
  21 + enable => true,
  22 + require => [
  23 + Package['httpd-devel'],
  24 + File['/etc/httpd/conf.d/playdoh.conf']
  25 + ];
  26 + }
  27 +
  28 + }
  29 + ubuntu: {
  30 + package { "apache2-dev":
  31 + ensure => present,
  32 + before => File['/etc/apache2/sites-enabled/playdoh.conf'];
  33 + }
  34 +
  35 + file { "/etc/apache2/sites-enabled/playdoh.conf":
  36 + source => "$PROJ_DIR/puppet/files/etc/httpd/conf.d/playdoh.conf",
  37 + owner => "root", group => "root", mode => 0644,
  38 + require => [
  39 + Package['apache2-dev']
  40 + ];
  41 + }
  42 +
  43 + service { "apache2":
  44 + ensure => running,
  45 + enable => true,
  46 + require => [
  47 + Package['apache2-dev'],
  48 + File['/etc/apache2/sites-enabled/playdoh.conf']
  49 + ];
  50 + }
  51 + }
  52 + }
  53 +}
3  puppet/manifests/classes/custom.pp
... ... @@ -0,0 +1,3 @@
  1 +# You can add custom puppet manifests for your app here.
  2 +class custom {
  3 +}
16 puppet/manifests/classes/init.pp
... ... @@ -0,0 +1,16 @@
  1 +# stage {"pre": before => Stage["main"]} class {'apt': stage => 'pre'}
  2 +
  3 +# Commands to run before all others in puppet.
  4 +class init {
  5 + group { "puppet":
  6 + ensure => "present",
  7 + }
  8 +
  9 + case $operatingsystem {
  10 + ubuntu: {
  11 + exec { "update_apt":
  12 + command => "/usr/bin/sudo /usr/bin/apt-get update",
  13 + }
  14 + }
  15 + }
  16 +}
14 puppet/manifests/classes/memcahed.pp
... ... @@ -0,0 +1,14 @@
  1 +# We use memcached in production, so we _should_ use it while
  2 +# we develop as well. That said, playdoh shouldn't *rely* on it
  3 +# entirely; it should work with any non-null cache store in Django.
  4 +class memcached {
  5 + package { "memcached":
  6 + ensure => installed;
  7 + }
  8 +
  9 + service { "memcached":
  10 + ensure => running,
  11 + enable => true,
  12 + require => Package['memcached'];
  13 + }
  14 +}
26 puppet/manifests/classes/mysql.pp
... ... @@ -0,0 +1,26 @@
  1 +# Get mysql up and running
  2 +class mysql {
  3 + package { "mysql-server":
  4 + ensure => installed;
  5 + }
  6 +
  7 + case $operatingsystem {
  8 + centos: {
  9 + package { "mysql-devel":
  10 + ensure => installed;
  11 + }
  12 + }
  13 +
  14 + ubuntu: {
  15 + package { "libmysqld-dev":
  16 + ensure => installed;
  17 + }
  18 + }
  19 + }
  20 +
  21 + service { "mysql":
  22 + ensure => running,
  23 + enable => true,
  24 + require => Package['mysql-server'];
  25 + }
  26 +}
32 puppet/manifests/classes/playdoh.pp
... ... @@ -0,0 +1,32 @@
  1 +# playdoh-specific commands that get playdoh all going so you don't
  2 +# have to.
  3 +
  4 +# TODO: Make this rely on things that are not straight-up exec.
  5 +class playdoh {
  6 + exec { "create_mysql_database":
  7 + command => "/usr/bin/mysqladmin -uroot create $DB_NAME",
  8 + unless => "/usr/bin/mysql -uroot -B --skip-column-names -e 'show databases' | /bin/grep '$DB_NAME'",
  9 + }
  10 +
  11 + exec { "grant_mysql_database":
  12 + command => "/usr/bin/mysql -uroot -B -e'GRANT ALL PRIVILEGES ON $DB_NAME.* TO $DB_USER@localhost # IDENTIFIED BY \"$DB_PASS\"'",
  13 + unless => "/usr/bin/mysql -uroot -B --skip-column-names mysql -e 'select user from user' | /bin/grep '$DB_USER'",
  14 + require => Exec["create_mysql_database"];
  15 + }
  16 +
  17 + exec { "syncdb":
  18 + cwd => "$PROJ_DIR",
  19 + command => "/usr/bin/python2.6 ./manage.py syncdb --noinput",
  20 + require => Exec["grant_mysql_database"];
  21 + }
  22 +
  23 + exec { "sql_migrate":
  24 + cwd => "$PROJ_DIR",
  25 + command => "/usr/bin/python2.6 ./vendor/src/schematic/schematic migrations/",
  26 + require => [
  27 + Service["mysql"],
  28 + Package["python2.6-dev", "libapache2-mod-wsgi", "python-wsgi-intercept" ],
  29 + Exec["syncdb"]
  30 + ];
  31 + }
  32 +}
34 puppet/manifests/classes/python.pp
... ... @@ -0,0 +1,34 @@
  1 +# Install python and compiled modules for project
  2 +class python {
  3 + case $operatingsystem {
  4 + centos: {
  5 + package {
  6 + [ "python26-devel", "python26-libs", "python26-distribute", "python26-mod_wsgi" ]:
  7 + ensure => installed;
  8 + }
  9 +
  10 + exec { "pip-install":
  11 + command => "/usr/bin/easy_install-2.6 -U pip",
  12 + creates => "/usr/bin/pip",
  13 + require => Package["python26-devel","python26-distribute"]
  14 + }
  15 +
  16 + exec { "pip-install-compiled":
  17 + command => "/usr/bin/pip install -r $PROJ_DIR/requirements/compiled.txt",
  18 + require => Exec['pip-install']
  19 + }
  20 + }
  21 +
  22 + ubuntu: {
  23 + package {
  24 + [ "python2.6-dev", "python2.6", "libapache2-mod-wsgi", "python-wsgi-intercept", "python-pip" ]:
  25 + ensure => installed;
  26 + }
  27 +
  28 + exec { "pip-install-compiled":
  29 + command => "/usr/bin/pip install -r $PROJ_DIR/requirements/compiled.txt",
  30 + require => Package['python-pip']
  31 + }
  32 + }
  33 + }
  34 +}
25 puppet/manifests/vagrant.pp
... ... @@ -0,0 +1,25 @@
  1 +#
  2 +# Playdoh puppet magic for dev boxes
  3 +#
  4 +import "classes/*.pp"
  5 +
  6 +$PROJ_DIR = "/home/vagrant/project"
  7 +
  8 +# You can make these less generic if you like, but these are box-specific
  9 +# so it's not required.
  10 +$DB_NAME = "playdoh_app"
  11 +$DB_USER = "root"
  12 +
  13 +class dev {
  14 + class {
  15 + init: before => Class[mysql];
  16 + mysql: before => Class[python];
  17 + python: before => Class[apache];
  18 + apache: before => Class[playdoh];
  19 + memcached: ;
  20 + playdoh: ;
  21 + custom: ;
  22 + }
  23 +}
  24 +
  25 +include dev
4 settings_local.py-dist
@@ -7,8 +7,8 @@ from settings import *
7 7 DATABASES = {
8 8 'default': {
9 9 'ENGINE': 'django.db.backends.mysql',
10   - 'NAME': '',
11   - 'USER': '',
  10 + 'NAME': 'playdoh_app',
  11 + 'USER': 'root',
12 12 'PASSWORD': '',
13 13 'HOST': '',
14 14 'PORT': '',
5 vagrantconfig.yaml
... ... @@ -0,0 +1,5 @@
  1 +# Default config for Vagrant
  2 +
  3 +# Don't change this; use vagrantconfig_local.yaml to override these
  4 +# settings instead.
  5 +nfs: false
5 vagrantconfig_local.yaml-dist
... ... @@ -0,0 +1,5 @@
  1 +# Configuration for Vagrant
  2 +
  3 +# Change to true if you can use nfs; using nfs significantly
  4 +# improves performance.
  5 +nfs: false

0 comments on commit 17137d2

Please sign in to comment.
Something went wrong with that request. Please try again.