diff options
Diffstat (limited to 'modules/django_application')
7 files changed, 46 insertions, 41 deletions
diff --git a/modules/django_application/files/custom_backend.py b/modules/django_application/files/custom_backend.py index 828744fb..5ab35385 100644 --- a/modules/django_application/files/custom_backend.py +++ b/modules/django_application/files/custom_backend.py @@ -1,9 +1,7 @@ -from django_auth_ldap.backend import LDAPBackend,_LDAPUser +from django_auth_ldap.backend import LDAPBackend,_LDAPUser class ForceUidLDAPBackend(LDAPBackend): def ldap_to_django_username(self, username): # force uid if someone give a email return _LDAPUser(self, username=username).attrs['uid'][0] - - diff --git a/modules/django_application/files/django_add_permission_to_group.py b/modules/django_application/files/django_add_permission_to_group.py index 4fa77e8d..69ac7be5 100644 --- a/modules/django_application/files/django_add_permission_to_group.py +++ b/modules/django_application/files/django_add_permission_to_group.py @@ -16,12 +16,12 @@ if app: permissions = permissions.filter(content_type__app_label__exact=app) if len(permissions) > 1: - print "Error, result not unique, please give the application among :" - print ' '.join([p.content_type.app_label for p in permissions]) - sys.exit(1) + print "Error, result not unique, please give the application among :" + print ' '.join([p.content_type.app_label for p in permissions]) + sys.exit(1) elif len(permissions) < 1: - print "Error, wrong codename" - sys.exit(1) + print "Error, wrong codename" + sys.exit(1) group.permissions.add(permissions[0]) group.save() diff --git a/modules/django_application/files/django_create_group.py b/modules/django_application/files/django_create_group.py index 69079f66..b5052217 100644 --- a/modules/django_application/files/django_create_group.py +++ b/modules/django_application/files/django_create_group.py @@ -8,5 +8,3 @@ try: except Group.DoesNotExist: group = Group.objects.create(name=group_name) group.save() - - diff --git a/modules/django_application/manifests/add_permission_to_group.pp b/modules/django_application/manifests/add_permission_to_group.pp new file mode 100644 index 00000000..6e0663ed --- /dev/null +++ b/modules/django_application/manifests/add_permission_to_group.pp @@ -0,0 +1,11 @@ +define django_application::add_permission_to_group( $path, + $module, + $group, + $app='') { + exec { "/usr/local/bin/django_add_permission_to_group.py ${group} ${name} ${app}": + user => 'root', + environment => ["DJANGO_SETTINGS_MODULE=${module}.settings", + "PYTHONPATH=${path}" ], + require => Django_application::Script['django_add_permission_to_group.py'] + } +} diff --git a/modules/django_application/manifests/create_group.pp b/modules/django_application/manifests/create_group.pp new file mode 100644 index 00000000..1931205f --- /dev/null +++ b/modules/django_application/manifests/create_group.pp @@ -0,0 +1,10 @@ +define django_application::create_group($path, $module) { + exec { "/usr/local/bin/django_create_group.py ${name}": + user => 'root', + environment => ["DJANGO_SETTINGS_MODULE=${module}.settings", + "PYTHONPATH=${path}" ], + require => Django_application::Script['django_create_group.py'] + } +} + + diff --git a/modules/django_application/manifests/init.pp b/modules/django_application/manifests/init.pp index 2fe9d2a2..f56f73ef 100644 --- a/modules/django_application/manifests/init.pp +++ b/modules/django_application/manifests/init.pp @@ -1,39 +1,18 @@ # this class hold the common stuff for all django applications -# as we cannot declare the same ressource twice ( ie, python-psycopg2 for example ) -# it is required to place this in a common class +# as we cannot declare the same resource twice ( ie, +# python-psycopg2 for example ) +# it is required to place this in a common class class django_application { - package { ['python-django','python-psycopg2','python-django-auth-ldap']: } + package {['python-django', + 'python-psycopg2', + 'python-django-auth-ldap']: } - file { "/usr/local/lib/custom_backend.py": - source => "puppet:///modules/django_application/custom_backend.py", + file { '/usr/local/lib/custom_backend.py': + source => 'puppet:///modules/django_application/custom_backend.py', notify => Service['apache'] } - define script() { - file { $name: - path => "/usr/local/bin/$name", - mode => 755, - source => "puppet:///modules/django_application/$name", - } - } - - script { ['django_create_group.py','django_add_permission_to_group.py']: } + django_application::script { ['django_create_group.py', + 'django_add_permission_to_group.py']: } - define create_group($path,$module) { - exec { "/usr/local/bin/django_create_group.py $name": - user => root, - environment => ["DJANGO_SETTINGS_MODULE=$module.settings", - "PYTHONPATH=$path" ], - require => Django_application::Script['django_create_group.py'] - } - } - - define add_permission_to_group($path,$module,$group, $app='') { - exec { "/usr/local/bin/django_add_permission_to_group.py $group $name $app": - user => root, - environment => ["DJANGO_SETTINGS_MODULE=$module.settings", - "PYTHONPATH=$path" ], - require => Django_application::Script['django_add_permission_to_group.py'] - } - } } diff --git a/modules/django_application/manifests/script.pp b/modules/django_application/manifests/script.pp new file mode 100644 index 00000000..f414d864 --- /dev/null +++ b/modules/django_application/manifests/script.pp @@ -0,0 +1,9 @@ +define django_application::script() { + file { $name: + path => "/usr/local/bin/${name}", + mode => '0755', + source => "puppet:///modules/django_application/${name}", + } +} + + |
