--- a/.hgignore Sun Feb 23 20:29:37 2014 +0000
+++ b/.hgignore Thu Feb 27 23:19:13 2014 +0100
@@ -9,10 +9,11 @@
develop-eggs
downloads
.settings
-
src/comt.egg-info
.installed.cfg
recreate
.pydevproject
settings_local.py
urls_local.py
+dev/.vagrant
+dev/custom.yaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgsub Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/Vagrantfile Thu Feb 27 23:19:13 2014 +0100
@@ -0,0 +1,124 @@
+# -*- 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: "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"
+
+ config.vm.define :coment_dev 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 = "coment_dev"
+ # # 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 "
+ 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 2014 +0100
@@ -0,0 +1,55 @@
+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'"
+ }
+
+ 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 { '172.16.1.2':
+ 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 Thu Feb 27 23:19:13 2014 +0100
@@ -0,0 +1,26 @@
+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)
+){
+
+ 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',
+ 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',
+ require => Exec['syncdb']
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/init.pp Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 2014 +0100
@@ -0,0 +1,31 @@
+
+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::db { $db_name:
+ user => $db_user,
+ password => postgresql_password($db_user, $db_pw),
+ 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 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 Thu Feb 27 23:19:13 2014 +0100
@@ -0,0 +1,80 @@
+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': '<%= @sdb_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://172.16.1.2/" # 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