|
|
@@ -1,140 +0,0 @@
|
|
1
|
|
-# Set default path for all Exec tasks
|
|
2
|
|
-Exec {
|
|
3
|
|
- path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
4
|
|
-}
|
|
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
|
|
- "libmysqlclient-dev",
|
|
17
|
|
- "git-core",
|
|
18
|
|
- ]
|
|
19
|
|
- package {
|
|
20
|
|
- $packages: ensure => installed,
|
|
21
|
|
- require => Exec["update-packages"]
|
|
22
|
|
- }
|
|
23
|
|
-}
|
|
24
|
|
-
|
|
25
|
|
-node precise64 {
|
|
26
|
|
-
|
|
27
|
|
- include python_dependencies
|
|
28
|
|
- include userconfig
|
|
29
|
|
-
|
|
30
|
|
- # Dev server on port 8080
|
|
31
|
|
- exec { "dev-server":
|
|
32
|
|
- command => "bash -c \"source /var/www/virtualenv/bin/activate && /vagrant/sites/sandbox/manage.py runserver 0.0.0.0:8080 &\"",
|
|
33
|
|
- }
|
|
34
|
|
-
|
|
35
|
|
- # Apache serving WSGI on port 80 (would prefer 8081)
|
|
36
|
|
- class {"apache": }
|
|
37
|
|
- class {"apache::mod::wsgi": }
|
|
38
|
|
- file {"/etc/apache2/sites-enabled/vagrant.conf":
|
|
39
|
|
- source => "/vagrant/sites/puppet/files/apache.conf"
|
|
40
|
|
- }
|
|
41
|
|
-
|
|
42
|
|
- # gunicorn serving WSGI on unix socket
|
|
43
|
|
- class { "python::gunicorn": owner => "root", group => "root" }
|
|
44
|
|
- python::gunicorn::instance { "oscar":
|
|
45
|
|
- venv => "/var/www/virtualenv",
|
|
46
|
|
- django => true,
|
|
47
|
|
- src => "/vagrant/sites/sandbox",
|
|
48
|
|
- }
|
|
49
|
|
-
|
|
50
|
|
- # Nginx in front of Apache (port 8082)
|
|
51
|
|
- class { "nginx": }
|
|
52
|
|
- nginx::resource::vhost { 'apache_rp':
|
|
53
|
|
- ensure => present,
|
|
54
|
|
- listen_port => 8082,
|
|
55
|
|
- }
|
|
56
|
|
- nginx::resource::location { 'apache-root':
|
|
57
|
|
- ensure => present,
|
|
58
|
|
- vhost => 'apache_rp',
|
|
59
|
|
- location => '/',
|
|
60
|
|
- proxy => 'http://localhost',
|
|
61
|
|
- proxy_set_headers => {
|
|
62
|
|
- 'REMOTE_ADDR' => '$remote_addr',
|
|
63
|
|
- 'HTTP_HOST' => '$http_host',
|
|
64
|
|
- },
|
|
65
|
|
- }
|
|
66
|
|
-
|
|
67
|
|
- # Nginx in front of gunicorn (port 8083)
|
|
68
|
|
- nginx::resource::vhost { 'gunicorn_rp':
|
|
69
|
|
- ensure => present,
|
|
70
|
|
- listen_port => 8083,
|
|
71
|
|
- }
|
|
72
|
|
- nginx::resource::location { 'gunicorn-root':
|
|
73
|
|
- ensure => present,
|
|
74
|
|
- vhost => 'gunicorn_rp',
|
|
75
|
|
- location => '/',
|
|
76
|
|
- proxy => 'http://app1',
|
|
77
|
|
- proxy_set_headers => {
|
|
78
|
|
- 'REMOTE_ADDR' => '$remote_addr',
|
|
79
|
|
- 'HTTP_HOST' => '$http_host',
|
|
80
|
|
- },
|
|
81
|
|
- }
|
|
82
|
|
- nginx::resource::upstream { 'app1':
|
|
83
|
|
- ensure => present,
|
|
84
|
|
- members => [
|
|
85
|
|
- 'unix:/run/gunicorn/oscar.sock weight=10',
|
|
86
|
|
- ],
|
|
87
|
|
- }
|
|
88
|
|
-
|
|
89
|
|
- # Memcached
|
|
90
|
|
- class {"memcached": max_memory => 64 }
|
|
91
|
|
-
|
|
92
|
|
- # Postgres
|
|
93
|
|
- $user = "oscar_user"
|
|
94
|
|
- $password = "oscar_password"
|
|
95
|
|
- $database_name = "oscar_vagrant"
|
|
96
|
|
- class {"postgresql::server": }
|
|
97
|
|
- pg_user {$user:
|
|
98
|
|
- ensure => present,
|
|
99
|
|
- password => $password,
|
|
100
|
|
- createdb => true,
|
|
101
|
|
- require => Class["postgresql::server"],
|
|
102
|
|
- }
|
|
103
|
|
- pg_database {$database_name:
|
|
104
|
|
- ensure => present,
|
|
105
|
|
- owner => $user,
|
|
106
|
|
- require => [Pg_user[$user]],
|
|
107
|
|
- encoding => "UTF8",
|
|
108
|
|
- }
|
|
109
|
|
-
|
|
110
|
|
- # MySQL
|
|
111
|
|
- class {"mysql::bindings": }
|
|
112
|
|
- class {"mysql::server":
|
|
113
|
|
- override_options => {"root_password" => "root_password"},
|
|
114
|
|
- }
|
|
115
|
|
- mysql::db {$database_name:
|
|
116
|
|
- user => $user,
|
|
117
|
|
- password => $password,
|
|
118
|
|
- host => "localhost",
|
|
119
|
|
- grant => ["all"],
|
|
120
|
|
- }
|
|
121
|
|
-
|
|
122
|
|
- # Python
|
|
123
|
|
- # - set-up a virtualenv
|
|
124
|
|
- # - install testing requirements
|
|
125
|
|
- # - install oscar in 'develop' mode
|
|
126
|
|
- $virtualenv = "/var/www/virtualenv"
|
|
127
|
|
- include python::dev
|
|
128
|
|
- include python::venv
|
|
129
|
|
- python::venv::isolate { $virtualenv:
|
|
130
|
|
- requirements => "/vagrant/requirements.txt"
|
|
131
|
|
- }
|
|
132
|
|
- python::pip::requirements {"/vagrant/requirements_vagrant.txt":
|
|
133
|
|
- venv => $virtualenv,
|
|
134
|
|
- require => Python::Venv::Isolate[$virtualenv]
|
|
135
|
|
- }
|
|
136
|
|
- exec {"install-oscar":
|
|
137
|
|
- command => "$virtualenv/bin/python /vagrant/setup.py develop",
|
|
138
|
|
- require => Python::Venv::Isolate[$virtualenv]
|
|
139
|
|
- }
|
|
140
|
|
-}
|