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 |
|
7 |
file { "/usr/local/lib/custom_backend.py": |
8 |
source => "puppet:///modules/django_application/custom_backend.py", |
9 |
notify => Service['apache'] |
10 |
} |
11 |
|
12 |
define script() { |
13 |
file { $name: |
14 |
path => "/usr/local/bin/$name", |
15 |
mode => 755, |
16 |
source => "puppet:///modules/django_application/$name", |
17 |
} |
18 |
} |
19 |
|
20 |
script { ['django_create_group.py','django_add_permission_to_group.py']: } |
21 |
|
22 |
define create_group($path,$module) { |
23 |
exec { "/usr/local/bin/django_create_group.py $name": |
24 |
user => root, |
25 |
environment => ["DJANGO_SETTINGS_MODULE=$module.settings", |
26 |
"PYTHONPATH=$path" ], |
27 |
require => Django_application::Script['django_create_group.py'] |
28 |
} |
29 |
} |
30 |
|
31 |
define add_permission_to_group($path,$module,$group, $app='') { |
32 |
exec { "/usr/local/bin/django_add_permission_to_group.py $group $name $app": |
33 |
user => root, |
34 |
environment => ["DJANGO_SETTINGS_MODULE=$module.settings", |
35 |
"PYTHONPATH=$path" ], |
36 |
require => Django_application::Script['django_add_permission_to_group.py'] |
37 |
} |
38 |
} |
39 |
} |