merge daf4516b022d
authorymh <ymh.work@gmail.com>
Fri, 07 Mar 2014 18:13:08 +0100
changeset 595 d3e56a41369e
parent 593 8156e6e3c503 (diff)
parent 594 daf4516b022d (current diff)
child 596 f36260133ed9
merge daf4516b022d
--- a/.hgignore	Thu Mar 06 19:04:47 2014 +0100
+++ b/.hgignore	Fri Mar 07 18:13:08 2014 +0100
@@ -9,10 +9,13 @@
 develop-eggs
 downloads
 .settings
-
 src/comt.egg-info
 .installed.cfg
 recreate
 .pydevproject
 settings_local.py
 urls_local.py
+dev/.vagrant
+dev/custom.yaml
+src/cm/scripts/test-suite/node_modules
+src/cm/scripts/test-suite//workspace.info.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgsub	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,6 @@
+dev/modules/nginx = [git]https://github.com/jfryman/puppet-nginx.git
+dev/modules/stdlib = [git]https://github.com/puppetlabs/puppetlabs-stdlib.git
+dev/modules/apt = [git]https://github.com/puppetlabs/puppetlabs-apt.git
+dev/modules/postgresql = [git]https://github.com/puppetlabs/puppetlabs-postgresql.git
+dev/modules/supervisord = [git]https://github.com/adedommelin/puppet-supervisord.git
+dev/modules/concat = [git]https://github.com/puppetlabs/puppetlabs-concat.git
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgsubstate	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,6 @@
+738ef15316fef7d3f82d9d29414f71445b3a35d9 dev/modules/apt
+24906d1bca3f8a1b93b24d71c0e081eda57afc9e dev/modules/concat
+7cf6dac978fe08e061ed9201284c7a5bf22af2a3 dev/modules/nginx
+0a8a9a5e1d375150398d70a0193ed99fbbc4e13d dev/modules/postgresql
+ab981422a67636441f1bfebaaade36aa690f1f25 dev/modules/stdlib
+743e2a3facfd7b9596983bca0f5afef8336ea525 dev/modules/supervisord
--- a/README.txt	Thu Mar 06 19:04:47 2014 +0100
+++ b/README.txt	Fri Mar 07 18:13:08 2014 +0100
@@ -42,7 +42,7 @@
 (all other python dependencies will be downloaded by buildout)
 
 Installation (development install)
-============
+==================================
 1. Install python2.5+ and all required libraries
 	(ubuntu users : 'sudo apt-get install python python-magic python-setuptools python-uno libyaml-0-1 python-yaml python-dev git-core python-utidylib python-pexpect python-cssutils')
 2. Install pandoc
@@ -85,8 +85,50 @@
    - `./bin/django runserver --settings=settings`
 11. Access your Comt instance by pointing your browser to http://127.0.0.1:8000/
 
+Installation (Vagrant development box)
+======================================
+
+The second option is to use the vagrant virtual machine defined in the `dev` folder.
+For this you need first to install Vagrant for your platform (c.f. http://www.vagrantup.com/), open a terminal in the `dev` folder and launch the command
+<code>
+$ vagrant up
+</code>
+This will create a virtual box, using the private address 172.16.1.2. An instance of comt can be reached at the following url http://172.16.1.2.
+
+The installation have the following parameters:
+  - The root of the project is mapped on `/srv/comt` on the dev box.
+  - The web server is nginx (http://nginx.org/).
+  - The web pages are served as a wsgi application with gunicorn (http://gunicorn.org/).
+  - The gunicorn processes are monitored by supervisor (http://supervisord.org/).
+  - Openoffice is installed but is not launched as an headless instance (althought it could be easily setup with supervisor).
+  - The dev box uses a virtual network with the ip 172.16.1.2 (this can be changed in the Vagrant config).
+  - The box is provisioned using puppet (http://puppetlabs.com/).
+  - Most of the configuration is don in the sysconfig module found in `dev/modules/sysconfig`.
+  - All the other subdirectories of `dev/modules` are puppet modules used during the box provisioning. All the folders are sub-repositories and are checked-out using git.
+
+Moreover, the following parameters are set :
+
+  | var name       | default     |
+  |----------------|-------------|
+  | db_name        | coment      |
+  | db_user        | coment_user |
+  | db_pw          | coment      |
+  | db_host        | 127.0.0.1   |
+  | db_port        | 5432        |
+  | superuser_name | admin       |
+  | superuser_pw   | dev@co-ment |
+
+These values can be overriden by creating a `custom.yaml` file in the `dev` folder. The file `custom.yaml.tmpl` gives a template for the format of this file.
+if the db_host is empty or 'localhost', or '127.0.0.1', the database is considered local to the box and a postgresql server is installed in the virtual server.
+Otherwise, the server is considered remote and only the postgresql client libraries are installed on the dev box.
+Also in this case, the database (db_name) and user (db_user) are not created automatically.
+You must ensure that they are already created on the postgresql server with the adequate authorizations, and that the user can connect on the 'remote' server from the dev box.
+
+Please refer to the available online documentation for more details on the various tools used here.
+
+
 Installation (production environment)
-=============
+=====================================
 This README.txt does not cover in details a production environment because this kind of setup is too platform dependant for us to provide a guide.
 A few tips thought:
 - recommended way to install it is using apache and wsgi, check out django installation guide at http://www.djangoproject.com/documentation/modpython/
@@ -116,7 +158,7 @@
 To use openoffice, on a development setup, you should make sure no openoffice process is left and launch `soffice -headless "-accept=socket,port=2002;urp;"` to start openoffice in background mode.
 
 Comt uses
-============
+=========
 
 Javascript libs used (and license) / shipped with the distribution
 ------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buildout-prod.cfg	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,11 @@
+[buildout]
+extends = buildout.cfg
+parts += gunicorn
+
+[gunicorn]
+recipe = zc.recipe.egg:scripts
+dependent-scripts = true
+eggs =
+    ${python:eggs}
+    eventlet
+    gunicorn
--- a/buildout.cfg	Thu Mar 06 19:04:47 2014 +0100
+++ b/buildout.cfg	Fri Mar 07 18:13:08 2014 +0100
@@ -1,16 +1,20 @@
 [buildout]
 newest=false
+find-links = http://download.berlios.de/utidylib/uTidylib-0.2.zip
 parts = 
 	django
 	python
 	django-extensions
-	django-piston
+	utidylib
 	omelette
 unzip = true
 develop = .
 
 [versions]
 django = 1.3
+utidylib = 0.2
+django-tagging = 0.3.1
+psycopg2 = 2.4.1
 
 [python]
 recipe = zc.recipe.egg
@@ -27,36 +31,40 @@
 #test = cm
 pythonpath = src
 	src/cm
+	extras
 	${django-extensions:location}
-	${django-piston:location}
 eggs = 
 	django-flash
 	django-tagging
-#	django-piston
+	django-piston
 # api dependency
 #	django-css	
-#	chardet
+	chardet
 	feedparser
-	PIL
+	Pillow
 	BeautifulSoup
 	html5lib
 	pytz
 	simplejson
 	pyyaml
 	south
-# psycopg2/mysql should be optional dependencies ... possible with buildout ???
-#	magic ???????? http://www.jsnp.net/code/magic.py ??? impossible to include this dependency
-#	utidylib ?????? http://download.berlios.de/utidylib/uTidylib-0.2.zip
+	psycopg2
+	utidylib
+        cssutils
+        pexpect
 
 [django-extensions]
 recipe=zerokspot.recipe.git
 repository=git://github.com/django-extensions/django-extensions.git
 #rev=7c73978b55fcadbe2cd6f2abbefbedb5a85c2c8c
 
-[django-piston]
-recipe = mercurialrecipe
-repository = http://bitbucket.org/jespern/django-piston
+
+[utidylib]
+recipe = zc.recipe.egg
+eggs = uTidylib
+
 
 [omelette]
 recipe = collective.recipe.omelette
 eggs = ${django:eggs}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/Vagrantfile	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,129 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  # All Vagrant configuration is done here. The most common configuration
+  # options are documented and commented below. For a complete reference,
+  # please see the online documentation at vagrantup.com.
+
+  # Every Vagrant virtual environment requires a box to build off of.
+  config.vm.box = "wheezy-73-x64"
+
+  # The url from where the 'config.vm.box' box will be fetched if it
+  # doesn't already exist on the user's system.
+  config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box"
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # config.vm.network :forwarded_port, guest: 80, host: 8080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  config.vm.network :private_network, ip: (ENV['VM_IP'] || "172.16.1.2")
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
+
+  # If true, then any SSH connections made will enable agent forwarding.
+  # Default value: false
+  # config.ssh.forward_agent = true
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  config.vm.synced_folder "../", "/srv/comt"
+
+  #vmname = "coment_dev_5311da30" #"coment_dev_"+Time.now.getutc.to_f.to_int.to_s(16)
+  vmname = "coment_dev"
+
+  config.vm.define :"#{vmname}" do |coment_dev|
+  end
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  config.vm.provider :virtualbox do |vb|
+      vb.name = vmname
+  #   # Don't boot with headless mode
+  #   vb.gui = true
+  #
+  #   # Use VBoxManage to customize the VM. For example to change memory:
+  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
+  end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
+
+  # Enable provisioning with Puppet stand alone.  Puppet manifests
+  # are contained in a directory path relative to this Vagrantfile.
+  # You will need to create the manifests directory and a manifest in
+  # the file base.pp in the manifests_path directory.
+  #
+  # An example Puppet manifest to provision the message of the day:
+  #
+  # # group { "puppet":
+  # #   ensure => "present",
+  # # }
+  # #
+  # # File { owner => 0, group => 0, mode => 0644 }
+  # #
+  # # file { '/etc/motd':
+  # #   content => "Welcome to your Vagrant-built virtual machine!
+  # #               Managed by Puppet.\n"
+  # # }
+  #
+  config.vm.provision :puppet do |puppet|
+    puppet.manifests_path = "manifests"
+    puppet.manifest_file  = "site.pp"
+    puppet.module_path    = "modules"
+    puppet.options        = "--hiera_config /vagrant/hiera.yaml "
+  #  puppet.options        = "--debug --verbose --hiera_config /vagrant/hiera.yaml "
+  end
+
+  # Enable provisioning with chef solo, specifying a cookbooks path, roles
+  # path, and data_bags path (all relative to this Vagrantfile), and adding
+  # some recipes and/or roles.
+  #
+  # config.vm.provision :chef_solo do |chef|
+  #   chef.cookbooks_path = "../my-recipes/cookbooks"
+  #   chef.roles_path = "../my-recipes/roles"
+  #   chef.data_bags_path = "../my-recipes/data_bags"
+  #   chef.add_recipe "mysql"
+  #   chef.add_role "web"
+  #
+  #   # You may also specify custom JSON attributes:
+  #   chef.json = { :mysql_password => "foo" }
+  # end
+
+  # Enable provisioning with chef server, specifying the chef server URL,
+  # and the path to the validation key (relative to this Vagrantfile).
+  #
+  # The Opscode Platform uses HTTPS. Substitute your organization for
+  # ORGNAME in the URL and validation key.
+  #
+  # If you have your own Chef Server, use the appropriate URL, which may be
+  # HTTP instead of HTTPS depending on your configuration. Also change the
+  # validation key to validation.pem.
+  #
+  # config.vm.provision :chef_client do |chef|
+  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+  #   chef.validation_key_path = "ORGNAME-validator.pem"
+  # end
+  #
+  # If you're using the Opscode platform, your validator client is
+  # ORGNAME-validator, replacing ORGNAME with your organization name.
+  #
+  # If you have your own Chef Server, the default validation client name is
+  # chef-validator, unless you changed the configuration.
+  #
+  #   chef.validation_client_name = "ORGNAME-validator"
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/custom.yaml.tmpl	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,9 @@
+---
+sysconfig::params::db_name : coment_custom
+sysconfig::params::db_user : coment_user_cutom
+sysconfig::params::db_pw   : coment_pw_custom
+sysconfig::params::db_host : 127.0.0.1_custom
+sysconfig::params::db_port : 5433
+
+sysconfig::params::superuser_name : admin_custom
+sysconfig::params::superuser_pw   : dev@co-ment_custom
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/hiera.yaml	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,7 @@
+---
+:hierarchy:
+  - custom
+:backends:
+  - yaml
+:yaml:
+  :datadir: '/vagrant/'
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/manifests/site.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,23 @@
+# upgrade system
+class { 'sysconfig::sys_upgrade': }
+
+# install packages
+class { 'sysconfig::packages': require => Class['sysconfig::sys_upgrade'] }
+
+# install postgres
+class { 'sysconfig::postgresql': require => Class['sysconfig::sys_upgrade'] }
+
+# install nginx
+class { 'sysconfig::nginx': require => Class['sysconfig::sys_upgrade'] }
+
+# create python
+class { 'sysconfig::buildout': require => [Class['sysconfig::packages'], Class['sysconfig::postgresql']] }
+
+# write config
+class { 'sysconfig::config': require => Class['sysconfig::buildout'] }
+
+# write django_init
+class { 'sysconfig::django_init': require => Class['sysconfig::config'] }
+
+# deploy
+class { 'sysconfig::deploy': require => [ Class['sysconfig::django_init'], Class['sysconfig::nginx'], Class['sysconfig::postgresql'] ] }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/buildout.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,18 @@
+class sysconfig::buildout {
+
+  exec {
+    'bootstrap':
+      command => '/usr/bin/python bootstrap.py',
+      cwd     => '/srv/comt',
+      creates => '/srv/comt/bin',
+      user    => 'vagrant';
+    'buildout':
+      command => '/srv/comt/bin/buildout -c /srv/comt/buildout-prod.cfg',
+      cwd     => '/srv/comt',
+      timeout => 0,
+      creates => '/srv/comt/bin/gunicorn';
+  }
+
+  Exec['bootstrap'] -> Exec['buildout']
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/config.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,29 @@
+class sysconfig::config(
+  $db_name = hiera('sysconfig::params::db_name',$sysconfig::params::db_name),
+  $db_user = hiera('sysconfig::params::db_user',$sysconfig::params::db_user),
+  $db_pw   = hiera('sysconfig::params::db_pw',$sysconfig::params::db_pw),
+  $db_host = hiera('sysconfig::params::db_host',$sysconfig::params::db_host),
+  $db_port = hiera('sysconfig::params::db_port',$sysconfig::params::db_port)
+) inherits sysconfig::params {
+
+  notify {'config': name => "config -> \$db_host: ${db_host}, \$db_port: ${db_port}, \$db_name: ${db_name}, \$db_user: ${db_user}, \$db_pw: ${db_pw}", withpath => true }
+
+  file { 'local-settings':
+     ensure  => 'present',
+     path    => "/srv/comt/src/cm/settings_local.py",
+     replace => 'no',
+     owner   => 'vagrant',
+     group   => 'vagrant',
+     mode    => 644,
+     content => template('sysconfig/settings_local.erb'),
+   }
+ 
+   file { 'media-root':
+     ensure => 'directory',
+     path   => '/srv/comt/web',
+     owner  => 'www-data',
+     group  => 'www-data',
+     mode   => '0775'
+   }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/deploy.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,65 @@
+class sysconfig::deploy {
+    
+    # create /var/run/gunicorn folder and insert entry in /etc/rc.local
+    file { 'run-folder':
+        path    => '/var/run/gunicorn',
+        ensure  => 'directory',
+        owner   => 'www-data',
+        group   => 'www-data',
+        mode    => '0775',
+    }
+
+    #create run folder for gunicorn
+    file { 'rc.local':
+        path    => '/etc/rc.local',
+        ensure  => 'present',
+        mode    => 755,
+        owner   => 'root',
+        group   => 'root',
+        content => template('sysconfig/rc.local.erb')
+    }
+
+    # install supervidsord
+    class { 'supervisord': }
+    
+    supervisord::program { 'coment' :
+        command      => '/srv/comt/bin/gunicorn -b unix:/var/run/gunicorn/comt.socket cm.wsgi:app',
+        user         => 'www-data',
+        directory    => '/srv/comt',
+        environment  => "PYTHONPATH='/srv/comt/src',PROJECT_PATH='/srv/comt/src/cm'",
+        require      => Class['supervisord']
+    }
+
+    supervisord::program { 'soffice' :
+        command      => '/usr/bin/soffice --headless "--accept=socket,port=2002;urp;"',
+        user         => 'vagrant',
+        directory    => '/srv/comt',
+        autostart    => false,
+        numprocs     => 1,
+        require      => Class['supervisord']
+    }
+
+    exec { 'reload_supervisor' :
+        command  => '/usr/bin/supervisorctl update',
+        require  => Supervisord::Program['coment']
+    }
+
+    #add site
+    nginx::resource::upstream { 'coment_app':
+        ensure                => present,
+        members               => [ 'unix:/var/run/gunicorn/comt.socket' ],
+        upstream_fail_timeout => 0,
+        require               => Exec['reload_supervisor']
+    }
+
+    nginx::resource::vhost { $ipaddress_eth1:
+        ensure           => present,
+        proxy            => 'http://coment_app',
+        proxy_set_header => ['Host $http_host'],
+        vhost_cfg_append => {
+            'proxy_redirect' => 'off'
+        },
+        require          => Nginx::Resource::Upstream['coment_app']
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/django_init.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,37 @@
+class sysconfig::django_init (
+    $superuser_name = hiera('sysconfig::params::superuser_name',$sysconfig::params::superuser_name),
+    $superuser_pw   = hiera('sysconfig::params::superuser_pw',$sysconfig::params::superuser_pw)
+) inherits sysconfig::params {
+    
+    notify {'django_init': name => "\$superuser_name : ${superuser_name}, \$superuser_pw : ${superuser_pw}", withpath => true }->
+
+    exec { 'syncdb':
+        command => '/srv/comt/bin/django syncdb --noinput --migrate',
+        user    => 'vagrant' 
+    }
+
+    exec { 'loaddata':
+        command => '/srv/comt/bin/django loaddata roles_generic',
+        user    => 'vagrant',
+        require => Exec['syncdb']
+    }
+
+    exec { 'createsuperuser':
+        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",
+        cwd     => '/srv/comt',
+        user    => 'vagrant',
+        onlyif  => "/bin/echo \"from django.contrib.auth.models import User; exit(User.objects.filter(username='${superuser_name}').count())\" | /srv/comt/bin/django shell",
+       require => Exec['syncdb']
+    }
+
+    file { 'karma_workspace_info':
+        ensure  => 'present',
+        path    => "/srv/comt/src/cm/scripts/test-suite/workspace.info.js",
+        replace => 'no',
+        owner   => 'vagrant',
+        group   => 'vagrant',
+        mode    => 644,
+        content => template('sysconfig/workspace.info.js.erb'),
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/init.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,4 @@
+
+class sysconfig {
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/nginx.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,6 @@
+class sysconfig::nginx {
+  # install nginx
+  class { '::nginx':}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/packages.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,34 @@
+class sysconfig::packages {
+
+  $coment_pkgs = [
+      'vim',
+      'python-setuptools',
+      'libpq-dev',
+      'python-dev',
+      'python-virtualenv',
+      'libjpeg8-dev',
+      'zlib1g-dev',
+      'libtiff5-dev',
+      'libfreetype6-dev',
+      'liblcms2-dev',
+      'libwebp-dev',
+      'tcl-dev',
+      'tk-dev',
+      'python-magic',
+      'mercurial',
+      'libtidy-dev',
+      'libyaml-dev',
+      'git-core',
+      'pandoc',
+      'abiword',
+      'libreoffice',
+      'libreoffice-script-provider-python',
+      'python-uno'
+  ]
+  
+  package { $coment_pkgs: ensure => "installed" }
+
+  #upgrade setuptools
+  exec { '/usr/bin/easy_install --upgrade setuptools': require => Package[$coment_pkgs]}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/params.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,15 @@
+class sysconfig::params {
+
+  $db_name = 'coment'
+  $db_user = 'coment_user'
+  $db_pw   = 'coment'
+  $db_host = '127.0.0.1'
+  $db_port = '5432'
+
+  $db_host_real = hiera('sysconfig::params::db_host',$db_host)
+  $db_is_local = ($db_host_real == undef or !$db_host_real or $db_host_real=='127.0.0.1' or $db_host_real=='localhost')
+
+  $superuser_name = 'admin'
+  $superuser_pw   = 'dev@co-ment'
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/postgresql.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,35 @@
+
+class sysconfig::postgresql (
+    $db_host    = hiera('sysconfig::params::db_host', $sysconfig::params::db_host),
+    $db_port    = hiera('sysconfig::params::db_port', $sysconfig::params::db_port),
+    $db_name    = hiera('sysconfig::params::db_name', $sysconfig::params::db_name),
+    $db_user    = hiera('sysconfig::params::db_user', $sysconfig::params::db_user),
+    $db_pw      = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw),
+) inherits sysconfig::params {
+
+    notify {'postgresql': name => "\$db_host : ${db_host}, \$db_port : ${db_port}, \$db_name : ${db_name}, \$db_user : ${db_user}, \$db_pw : ${db_pw}", withpath => true }
+
+    if $sysconfig::params::db_is_local {
+        class { 'postgresql::server': }
+
+        postgresql::server::role {"${db_user}_createdb":
+            username      => $db_user,
+            createdb      => true,
+            password_hash => postgresql_password($db_user, $db_pw)
+        }->
+        postgresql::server::database { $db_name:
+            owner    => $db_user,            
+            encoding => 'UTF8',
+        }
+    }
+    else {
+        class { 'postgresql::client': }->
+        postgresql::validate_db_connection { 'validate_postgres_connection':
+            database_host           => $db_host,
+            database_port           => $db_port,
+            database_username       => $db_user,
+            database_password       => $db_pw,
+            database_name           => $db_name,
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/sys_upgrade.pp	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,21 @@
+class sysconfig::sys_upgrade {
+
+  exec {
+    'apt_get_update_sysconfig':
+      command     => '/usr/bin/apt-get update',
+      timeout     => 2400,
+      returns     => [ 0, 100 ];
+#      refreshonly => true;
+    'sys-upgrade':
+      command   => '/usr/bin/apt-get upgrade -y',
+      timeout => 0,
+      require   => Exec['apt_get_update_sysconfig'];
+    'sys-dist-upgrade':
+      command   => '/usr/bin/apt-get dist-upgrade -y',
+      timeout => 0,
+      require   => Exec['apt_get_update_sysconfig'];
+  }
+
+  Exec['sys-upgrade'] -> Exec['sys-dist-upgrade']
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/rc.local.erb	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+#
+# By default this script does nothing.
+
+if [ ! -d /var/run/gunicorn ]; then
+  mkdir /var/run/gunicorn/
+  chown www-data:www-data /var/run/gunicorn/
+fi
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/settings_local.erb	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,87 @@
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+CLIENT_DEBUG = DEBUG
+
+YUI_DEBUG = DEBUG # use expanded yui version (i.e. not -min)
+YUI_DISTANT = False
+
+DATABASES = {
+  'default': {
+    'ENGINE': 'postgresql_psycopg2', # YOUR_SETTINGS # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+    'NAME': '<%= @db_name %>',               # YOUR_SETTINGS # Or path to database file if using sqlite3.
+    'USER': '<%= @db_user %>',               # YOUR_SETTINGS # Not used with sqlite3.
+    'PASSWORD': '<%= @db_pw %>',             # YOUR_SETTINGS # Not used with sqlite3.
+    'HOST': '<%= @db_host %>',                      # YOUR_SETTINGS # Set to empty string for localhost. Not used with sqlite3.
+    'PORT': '<%= @db_port %>',                      # YOUR_SETTINGS # Set to empty string for default. Not used with sqlite3.
+   }
+}
+
+SITE_URL = "http://<%= @ipaddress_eth1 %>/" # YOUR_SETTINGS
+
+DEFAULT_FROM_EMAIL = "me@example.com" # YOUR_SETTINGS
+
+# destination email for the contact page
+CONTACT_DEST = DEFAULT_FROM_EMAIL
+
+# smtp host
+EMAIL_HOST = "localhost" # YOUR_SETTINGS
+
+TEMPLATE_STRING_IF_INVALID = "NNNNNNNNNOOOOOOOOOOOOOOO" if DEBUG else ''
+
+# web server writable directory to store Comt uploaded content (text images etc.)
+MEDIA_ROOT = '/srv/comt/web' # YOUR_SETTINGS
+
+# Insert some random text here, 
+# it will be used to add some randomness to every crypto operation Comt does
+SECRET_KEY = '<%= Array.new(50){"abcdefghijklmnopqrstuvwxyz0123456789!@#\$%^&*(-_=+)".split("").sample}.join %>' # YOUR_SETTINGS
+
+MEDIA_URL = '/site_media/'
+
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.admin',
+    'cm',
+#    'django_extensions',
+    'tagging',
+    'south',
+)
+
+CM_MEDIA_PREFIX = '/cmmedia/'
+
+ADMIN_MEDIA_PREFIX = '/media/'
+
+ADMINS = (
+    ('Comt admin', CONTACT_DEST),
+)
+
+MANAGERS = ADMINS
+SEND_BROKEN_LINK_EMAILS = False
+
+SERVER_EMAIL = DEFAULT_FROM_EMAIL
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+DEFAULT_TIME_ZONE = "Europe/Paris"
+
+# Do not use name/email of co-ment users but rather
+# those passed in the request.
+# Set this parameter to True when using co-ment from
+# a third-party CMS throuch co-ment API.
+DECORATED_CREATORS = False
+
+# Set to TRUE to use Abiword for convertion form and to legacy formats.
+# Set to False to use LibreOffice for convertion form and to legacy formats.
+USE_ABI = True
+
+# Set to True if you don't want to appear in Sopinspace Piwik statistics
+DISABLE_TRACKING = True
+
+#disable email reporting by piston
+PISTON_EMAIL_ERRORS = False
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/workspace.info.js.erb	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,27 @@
+
+function define (name, value) {
+    Object.defineProperty (exports, name, {
+        value:      value,
+        enumerable: true
+    }); 
+}
+
+define ("WORKSPACE_URL", 'http://<%= @ipaddress_eth1 %>/');
+define ("USER_ADMIN", '<%= @superuser_name %>');
+define ("PASS_ADMIN", '<%= @superuser_pw %>');
+
+define ("BROWSERS", ['PhantomJS']);
+
+// TODO: decide wether we should populate workspaces with standard users or
+// create them on the fly ?
+
+define ("USER_EDIT", '');
+define ("PASS_EDIT", '');
+
+define ("USER_COM", '');
+define ("PASS_COM", '');
+
+define ("USER_OBSERV", '');
+define ("PASS_OBSERV", '');
+
+
--- a/src/cm/activity.py	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/activity.py	Fri Mar 07 18:13:08 2014 +0100
@@ -31,7 +31,7 @@
         originator_user = request.user
     
     if STORE_ACTIVITY_IP:
-        ip = request.META['REMOTE_ADDR']
+        ip = request.META.get('REMOTE_ADDR', '0.0.0.0')
     else:
         ip = None
     
--- a/src/cm/scripts/test-suite/karma.conf.js	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/scripts/test-suite/karma.conf.js	Fri Mar 07 18:13:08 2014 +0100
@@ -1,6 +1,7 @@
 // Karma configuration
 // Generated on Wed Jan 29 2014 15:32:16 GMT+0100 (CET)
 
+
 // SID: get WORKSPACE_URL configuration from one single file to customize
 var w = require ('./workspace.info.js');
 
@@ -17,7 +18,7 @@
 		// - Firefox	; Safari	(only Mac; run `npm install karma-safari-launcher` first)
 		// - Chrome		; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
 		// - PhantomJS	; IE		(only Windows; run `npm install karma-ie-launcher` first)
-		browsers: ['Chrome'],
+		browsers: w.BROWSERS,
 		// frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
 		frameworks: ['mocha', 'karma-e2e-dsl'],
 		// SID: Karma will start and run somewhere else than '/', to allow proxying '/'
--- a/src/cm/scripts/test-suite/start-test-suite.sh	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/scripts/test-suite/start-test-suite.sh	Fri Mar 07 18:13:08 2014 +0100
@@ -1,5 +1,17 @@
 #!/bin/bash
 
-export CHROME_BIN=`whereis chromium | sed -r 's/[^ ]* ([^ ]*).*/\1/g' -`
-karma start
+export CHROME_BIN= `which chromium`
+if [ -z "$CHROME_BIN" ]; then
+    export CHROME_BIN=`which chrome`
+fi
+export PHANTOMJS_BIN=`which phantomjs`
 
+if [ -x ./node_modules/.bin/karma ]; then
+   KARMA=./node_modules/.bin/karma
+else
+   KARMA=`which karma`
+fi
+
+"$KARMA" start
+
+
--- a/src/cm/scripts/test-suite/workspace.info.js	Thu Mar 06 19:04:47 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-
-define ("WORKSPACE_URL", 'http://192.168.2.61:8000/');
-define ("USER_ADMIN", 'siltaar');
-define ("PASS_ADMIN", 'oaueoaue');
-
-// TODO: decide wether we should populate workspaces with standard users or
-// create them on the fly ?
-
-define ("USER_EDIT", '');
-define ("PASS_EDIT", '');
-
-define ("USER_COM", '');
-define ("PASS_COM", '');
-
-define ("USER_OBSERV", '');
-define ("PASS_OBSERV", '');
-
-function define (name, value) {
-    Object.defineProperty (exports, name, {
-        value:      value,
-        enumerable: true
-    });
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/workspace.info.js.tmpl	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,27 @@
+
+define ("WORKSPACE_URL", '<workspace-url>');
+define ("USER_ADMIN", '<admin-login>');
+define ("PASS_ADMIN", '<admin-password>');
+
+define ("BROWSERS", ['Chrome']);
+
+// TODO: decide wether we should populate workspaces with standard users or
+// create them on the fly ?
+
+define ("USER_EDIT", '');
+define ("PASS_EDIT", '');
+
+define ("USER_COM", '');
+define ("PASS_COM", '');
+
+define ("USER_OBSERV", '');
+define ("PASS_OBSERV", '');
+
+function define (name, value) {
+    Object.defineProperty (exports, name, {
+        value:      value,
+        enumerable: true
+    });
+}
+
+
--- a/src/cm/tests/test_api.py	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/tests/test_api.py	Fri Mar 07 18:13:08 2014 +0100
@@ -22,7 +22,7 @@
         self.user = user
 
 class APITest(TestCase):
-    fixtures = ['roles_generic', 'test_content', ]
+    fixtures = ['initial_data','roles_generic', 'test_content', ]
     
     def test_text_get(self):
         """
--- a/src/cm/tests/test_notifications.py	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/tests/test_notifications.py	Fri Mar 07 18:13:08 2014 +0100
@@ -7,7 +7,7 @@
 from cm.models_utils import *
 
 class NotificationTest(TestCase):
-    fixtures = ['roles_generic','test_content']
+    fixtures = ['initial_data', 'roles_generic','test_content']
     
     def setUp(self):
         pass
--- a/src/cm/tests/test_security.py	Thu Mar 06 19:04:47 2014 +0100
+++ b/src/cm/tests/test_security.py	Fri Mar 07 18:13:08 2014 +0100
@@ -12,7 +12,7 @@
         self.user = user
 
 class SecurityTest(TestCase):
-    fixtures = ['roles_generic','test_content']
+    fixtures = ['initial_data','roles_generic','test_content']
     
     def test_access_rights(self):
         # anon user sees no text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/wsgi.py	Fri Mar 07 18:13:08 2014 +0100
@@ -0,0 +1,11 @@
+import os
+import sys
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'cm.settings'
+
+path = os.environ['PROJECT_PATH']
+if path not in sys.path:
+    sys.path.append(path)
+
+import django.core.handlers.wsgi
+app = django.core.handlers.wsgi.WSGIHandler()