Browse Source

Add Postgres support to Vagrant machine

master
David Winterbottom 12 years ago
parent
commit
5ee2541bc7
3 changed files with 46 additions and 5 deletions
  1. 2
    0
      Makefile
  2. 38
    1
      sites/puppet/manifests/site.pp
  3. 6
    4
      sites/sandbox/settings_postgres.py

+ 2
- 0
Makefile View File

@@ -42,6 +42,8 @@ i18n:
42 42
 
43 43
 puppet:
44 44
 	# Install puppet modules required to set-up a Vagrant box
45
+	rm -rf sites/puppet/modules/*
45 46
 	puppet module install --target-dir sites/puppet/modules/ saz-memcached -v 2.0.2
47
+	git clone git://github.com/akumria/puppet-postgresql.git sites/puppet/modules/postgresql
46 48
 	git clone git://github.com/uggedal/puppet-module-python.git sites/puppet/modules/python
47 49
 	git clone git://github.com/codeinthehole/puppet-userconfig.git sites/puppet/modules/userconfig

+ 38
- 1
sites/puppet/manifests/site.pp View File

@@ -3,12 +3,49 @@ Exec {
3 3
 	path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
4 4
 }
5 5
 
6
+class python_dependencies {
7
+	exec {"update-packages":
8
+		command => "apt-get update",
9
+	}
10
+    $packages = [
11
+		"build-essential",
12
+		"python-setuptools",
13
+		"python-imaging",
14
+		"python-memcache",
15
+		"postgresql-server-dev-9.1",
16
+    ]
17
+    package {
18
+        $packages: ensure => installed,
19
+		require => Exec["update-packages"]
20
+    }
21
+}
22
+
6 23
 node precise64 {
24
+
25
+	include python_dependencies
7 26
 	include userconfig
8 27
 
9 28
 	# Memcached
10 29
 	class {"memcached": max_memory => 64 }
11 30
 
31
+	# Postgres
32
+	$user = "oscar_user"
33
+	$password = "oscar_password"
34
+	$database_name = "oscar_vagrant"
35
+	class {"postgresql::server": }
36
+	pg_user {$user:
37
+		ensure => present,
38
+		password => $password,
39
+		createdb => true,
40
+		require => Class["postgresql::server"],
41
+	}
42
+	pg_database {$database_name:
43
+		ensure => present,
44
+		owner => $user,
45
+		require => [Pg_user[$user]],
46
+		encoding => "UTF8",
47
+	}
48
+
12 49
 	# Python
13 50
 	# - set-up a virtualenv
14 51
 	# - install testing requirements
@@ -20,7 +57,7 @@ node precise64 {
20 57
 	    requirements => "/vagrant/requirements.txt"
21 58
 	}
22 59
     exec {"install-oscar":
23
-	    command => "cd /vagrant && $virtualenv/bin/python setup.py develop",
60
+	    command => "$virtualenv/bin/python setup.py develop",
24 61
 		require => Python::Venv::Isolate[$virtualenv]
25 62
 	}
26 63
 }

+ 6
- 4
sites/sandbox/settings_postgres.py View File

@@ -1,10 +1,12 @@
1
+from settings import *
2
+
1 3
 DATABASES = {
2 4
     'default': {
3
-        'ENGINE': 'django.contrib.gis.db.backends.postgis',
4
-        'NAME': 'oscar',
5
-        'USER': 'oscar_vagrant',
5
+        'ENGINE': 'django.db.backends.postgresql_psycopg2',
6
+        'NAME': 'oscar_vagrant',
7
+        'USER': 'oscar_user',
6 8
         'PASSWORD': 'oscar_password',
7
-        'HOST': '',
9
+        'HOST': '127.0.0.1',
8 10
         'PORT': '',
9 11
     }
10 12
 }

Loading…
Cancel
Save