aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2011-02-24 18:52:53 +0000
committerMichael Scherer <misc@mageia.org>2011-02-24 18:52:53 +0000
commitaa71fc9da407f9bc8fac061f5316498294f61759 (patch)
tree638da1a5efe23200c63d40273bf4dc3b1cd70caa
parentef45852d0d31fdd1daa39f603cd12171d63a5116 (diff)
downloadpuppet-aa71fc9da407f9bc8fac061f5316498294f61759.tar
puppet-aa71fc9da407f9bc8fac061f5316498294f61759.tar.gz
puppet-aa71fc9da407f9bc8fac061f5316498294f61759.tar.bz2
puppet-aa71fc9da407f9bc8fac061f5316498294f61759.tar.xz
puppet-aa71fc9da407f9bc8fac061f5316498294f61759.zip
- add 2 class to add group to a django application, as well as
permission ( used for tx )
-rw-r--r--modules/django_application/files/django_add_permission_to_group.py11
-rw-r--r--modules/django_application/files/django_create_group.py12
-rw-r--r--modules/django_application/manifests/init.pp32
3 files changed, 55 insertions, 0 deletions
diff --git a/modules/django_application/files/django_add_permission_to_group.py b/modules/django_application/files/django_add_permission_to_group.py
new file mode 100644
index 00000000..c5edc31c
--- /dev/null
+++ b/modules/django_application/files/django_add_permission_to_group.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+import sys
+group_name = sys.argv[1]
+permission = sys.argv[2]
+
+from django.contrib.auth.models import Group,Permission
+g = Group.objects.get(name=group_name)
+p = Permission.objects.get(codename=permission)
+
+g.permissions.add(p)
+g.save()
diff --git a/modules/django_application/files/django_create_group.py b/modules/django_application/files/django_create_group.py
new file mode 100644
index 00000000..69079f66
--- /dev/null
+++ b/modules/django_application/files/django_create_group.py
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+import sys
+group_name = sys.argv[1]
+
+from django.contrib.auth.models import Group
+try:
+ group = Group.objects.get(name=group_name)
+except Group.DoesNotExist:
+ group = Group.objects.create(name=group_name)
+ group.save()
+
+
diff --git a/modules/django_application/manifests/init.pp b/modules/django_application/manifests/init.pp
index 522f4472..d8bedbef 100644
--- a/modules/django_application/manifests/init.pp
+++ b/modules/django_application/manifests/init.pp
@@ -15,4 +15,36 @@ class django_application {
source => "puppet:///modules/django_application/custom_backend.py",
notify => Service['apache']
}
+
+ define script() {
+ file { $name:
+ path => "/usr/local/bin/$name",
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => 755,
+ source => "puppet:///modules/django_application/$name",
+ }
+ }
+
+ 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) {
+ exec { "/usr/local/bin/django_add_permission_to_group.py $group $name":
+ user => root,
+ environment => ["DJANGO_SETTINGS_MODULE=$module.settings",
+ "PYTHONPATH=$path" ],
+ require => Django_application::Script['django_add_permission_to_group.py']
+ }
+ }
}