* * *
**`charm name: django-rainbow`**
*Django-rainbow* is designed to automate deployment of Django web projects
to the cloud. Any Django project which resides on a hosted mercurial (hg) repository can be deployed using this charm.
Django-rainbow is a solid tool with a forgiving design regarding re-triggering.
Data is safe from deletion without becoming isolated from the charm. Database and project data are never removed, replaced, or deleted. This charm does not require additional packages or have any dependencies outside of juju. All scripts are written in/for the Bash shell using Ubuntu 12.04 64 bit (Precise Pangolin).
>Put Django-rainbow into a local charm repository.
>Edit the *config.yaml* file with your django-rainbow project customizations.
>Deploy the charm with --> *juju deploy --repository=. local:precise/django-rainbow*
>Edit the secondary project config file. This file is called
*your-project.yaml* by default.
>The renamed *your-project.yaml* file is deployed with -->
*juju set django-rainbow --config /path/to/your-project.yaml*
>Trigger the config-changed hook to update or add a project to the instance --> *juju set --config=/path/to/your-project.yaml django-rainbow*.
* * *
It is expected to store the *your-project.yaml* files in a direcory for future use. These project config files can be distributed, allowing anyone to launch the project to the cloud. The project must reside on a hosted third party mercurial repository, e.g. Bit Bucket. When the project config file is customized, the config-changed hook will,
>- Create or update the virtual host provided in the *your-project.yaml* file and place it in the Apache2 sites-available directory.
>- Pull or update the project from the hosted repository to the directory listed as: *DocumentRoot* in the provided virtual host. Note: Any changes to the repository will be public immediately.
>- Parse the project *settings.py* file for database,project settings, and a time stamp.
>- Create or update the database, user, and tables with mysql and/or configure the project.
Logging files contain any run-time errors according to the current revision number. Installation logs use the integer in the *revision* file of the charm base directory. Configuration logs will use the *revision* number set in the *your-project.yaml* or *config.yaml* files. These logs only contain critical errors throughout hook run-time. This allows for simple debugging regarding django-rainbow development.
This file is the primary settings for django-rainbow. All of the settings set in this file will install with django-rainbow. It is reasonable to include project settings in here if there is to be only one project per django-rainbow instance. If you wish to launch many Django projects per instance, the *your-project.yaml* file will need to be utilized.
All settings in this file relate to a specific Django project repository. It is expected to rename and store this file separate from the charm. One can keep many of these yaml files handy to launch or update live Django projects.
> **-Package installation-**
Django-rainbow will automatically fetch and search your package urls for either
*setup.py* or *configure* scripts. The first match in the lowest section of the directory is assumed the installation type, e.g. Python install is assumed if setup.py is found in the next directory and a configure script in a subsequent directory of the extracted package. This applies to all package urls provided in both the *config.yaml* and *your-project.yaml* file except for the apt-get and pip packages. With this, one can include a git repository with either *setup.py* or binary compilation *configure* script. After, make, make install, commands will be issued if appropriate. Note: Remember to include a gcc compiler and any dependencies if binary code is to be fetched and compiled.
> **-Sites Framework-**
The Django sites framework can be administered through django-rainbow. Project sites tables are created through fixture files kept in the base directory of the project. The *project-site-name* and *project-site-domain* option need to be set for this to happen. Also, django-rainbow will parse you project *settings.py* file for a *SITE_ID* declaration and *django.contrib.sites* listed in *installed_apps*. **All of the above conditions need to be satisfied to allow django.sites framework updating.** The sites framework will only update the first time the *config-changed* hook is ran. All subsequent re-triggering will maintain the initial setting of the: name, domain, and SITE_ID (this includes null settings). After the first *config-changed* run, setting the *always-update-sites-framework* is the only method to update the sites framework. Note: this is the only way to load other fixture files in your project.
> **-Database synchronization-**
A *python manage.py syncdb* is only necessary when *settings.py* changes have occurred. For this reason, django-rainbow maintains a current time stamp of the *settings.py* file. When the *settings.py* file is modified, the *config-changed* hook will issue a *python manage.py syncdb* command. While it is redundant, this command can be ran every time a project is updated by setting the *always-update-database* option.
> **-Installation files-**
The *rainbow-installation-directory* option sets the base directory for all django-rainbow project settings. This includes: logging, configuration files, package source files, and other django-rainbow related data.
All django-rainbow data files and package source are stored below the directory set by the *rainbow-installation-directory* option. This directory holds
*1)* Make sure when the project repository is pulled onto the server for the first time, the *DocumentRoot* directory listed in the virtual host is the base directory of the project. This may require changing the project repository directory structure or virtual host settings a bit.
*2)* Do not edit any repository data on the instance. This data will be lost with the next *config-changed* hook. The project should only be updated by a config-changed trigger. This is what the revision setting is for in the config files.
*3)* A *juju set django-rainbow --config /path/to/your-project.yaml* will trigger the config-changed hook trigger. For single projects with the config.yaml file, a *juju set django-rainbow revision=[num]* can be used.
*4)* All of the django-rainbow data files are kept in the directory specified with the *rainbow-installation-directory:* option in config.yaml.
*5)* Many of the django-rainbow settings are described/explained in the config.yaml option descriptions.
*6)* Comment out the *set -eux* command in the config-changed and install hooks. This will prevent plain text printing of your repository password.
* * *
Django Rainbow is a generic platform to deploy Django projects. Don't expect too much versatility.
*1)* Django-rainbow only supports Mercurial and Bit bucket for project code hosting.
*2)* The only supported project database is mysql.
Robert Edward Steckroth II
Django Rainbow is a charm written for Juju
Copyright (C) 2012 Robert Edward Steckroth II
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/)
|2012/07/26 Surgemcgee completed the Django-rainbow charm.
Testing and stability checks are finished.
Going for review and (revno 23)
|2012/07/18 Surgemcgee added fixtures support for project and use it with the django.sites framework.
added options for dat (revno 22)
|2012/07/12 Surgemcgee updated todo list and forgot the python manage.py loaddata command.
|2012/07/12 Surgemcgee added fixture yaml for sites framework. This will allow for database independants.
|2012/07/05 Surgemcgee added better code desing, coherency, and bug fixes.
Packages are installed in the config-changed hoo (revno 19)
|2012/06/28 Surgemcgee Fixed a directory typo in config-changed hook
|2012/06/26 Surgemcgee Fixed tar ball extraction with spaces in entries.
Better support for mysql user creation with databa (revno 17)
|2012/06/25 Surgemcgee Gramerical errors fixed in documentation.
|2012/06/25 Surgemcgee Added binary compilation method.
Added better package support and mercurial