dev/modules/sysconfig/manifests/django_init.pp
author ymh <ymh.work@gmail.com>
Thu, 27 Feb 2014 23:19:13 +0100
changeset 587 a1aa29e7809f
child 588 8e9ea314e06e
permissions -rw-r--r--
add a vagrant profile + puppet config for dev box
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
class sysconfig::django_init (
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
    $superuser_name = hiera('sysconfig::params::superuser_name',$sysconfig::params::superuser_name),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
    $superuser_pw   = hiera('sysconfig::params::superuser_pw',$sysconfig::params::superuser_pw)
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
){
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
    
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
    notify {'django_init': name => "\$superuser_name : ${superuser_name}, \$superuser_pw : ${superuser_pw}", withpath => true }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
    exec { 'syncdb':
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
        command => '/srv/comt/bin/django syncdb --noinput --migrate',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
        user    => 'vagrant' 
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    exec { 'loaddata':
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
        command => '/srv/comt/bin/django loaddata roles_generic',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
        user    => 'vagrant',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
        require => Exec['syncdb']
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    exec { 'createsuperuser':
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        command => '/bin/echo "from django.contrib.auth.models import User; User.objects.create_superuser(\'$superuser_name\', \'admin@example.com\', \'$superuser_pw\')" | /srv/comt/bin/django shell',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        cwd     => '/srv/comt',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        user    => 'vagrant',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        unless  => '/bin/echo "from django.contrib.auth.models import User; exit(0) if User.objects.filter(username=\'$superuser_name\').count() else exit(1)" | /srv/comt/bin/django shell',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
        require => Exec['syncdb']
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
}