1 |
# this class hold the common stuff for all django applications |
2 |
# as we cannot declare the same ressource twice ( ie, python-psycopg2 for example ) |
3 |
# it is required to place this in a common class |
4 |
class django_application { |
5 |
package { ['python-django','python-psycopg2','python-django-auth-ldap']: |
6 |
ensure => installed |
7 |
} |
8 |
|
9 |
file { "custom_backend.py": |
10 |
path => "/usr/local/lib/custom_backend.py", |
11 |
ensure => present, |
12 |
owner => root, |
13 |
group => root, |
14 |
mode => 644, |
15 |
source => "puppet:///modules/django_application/custom_backend.py", |
16 |
notify => Service['apache'] |
17 |
} |
18 |
|
19 |
define script() { |
20 |
file { $name: |
21 |
path => "/usr/local/bin/$name", |
22 |
ensure => present, |
23 |
owner => root, |
24 |
group => root, |
25 |
mode => 755, |
26 |
source => "puppet:///modules/django_application/$name", |
27 |
} |
28 |
} |
29 |
|
30 |
script { ['django_create_group.py','django_add_permission_to_group.py']: |
31 |
} |
32 |
|
33 |
define create_group($path,$module) { |
34 |
exec { "/usr/local/bin/django_create_group.py $name": |
35 |
user => root, |
36 |
environment => ["DJANGO_SETTINGS_MODULE=$module.settings", |
37 |
"PYTHONPATH=$path" ], |
38 |
require => Django_application::Script['django_create_group.py'] |
39 |
} |
40 |
} |
41 |
|
42 |
define add_permission_to_group($path,$module,$group) { |
43 |
exec { "/usr/local/bin/django_add_permission_to_group.py $group $name": |
44 |
user => root, |
45 |
environment => ["DJANGO_SETTINGS_MODULE=$module.settings", |
46 |
"PYTHONPATH=$path" ], |
47 |
require => Django_application::Script['django_add_permission_to_group.py'] |
48 |
} |
49 |
} |
50 |
} |