nephila/stable/: nephila-fab-0.4.2 metadata and description

Homepage | Simple index

Fabric task for managing nephila django projects

author Nephila
author_email info@nephila.it
classifiers
  • Development Status :: 4 - Beta
  • Environment :: Web Environment
  • Framework :: Django
  • Intended Audience :: Developers
  • Operating System :: OS Independent
  • Programming Language :: Python
  • Topic :: Internet :: WWW/HTTP :: Dynamic Content
  • Topic :: Software Development
  • Topic :: Software Development :: Libraries :: Application Frameworks
license see LICENCE.txt
platform
  • OS Independent

Because this project isn't in the mirror_whitelist, no releases from root/pypi are included.

File Tox results History
nephila-fab-0.4.2.tar.gz
Size
21 KB
Type
Source
nephila_fab-0.4.2-py2-none-any.whl
Size
30 KB
Type
Python Wheel
Python
2

Introduction

At the end of this tutorial, you will have basic knowledge of komaci project startup, configuration and you will know some of the komaci plugins.

Prepare the environment

For the tutorial to succeed, you need a proper python 2.6 or 2.7 environment set up.

Requirements

You need these packages installed in your Python 2.6 or 2.7 environment:

psycopg2
fabric

Then add this to your ~/.ssh/config file:

Host gitix.iast.it
    IdentityFile /path/to/your/id_rsa
    HostName 62.48.49.33
    Port 1022
    User git
    Compression yes
    CompressionLevel 9

Remember to change the path of your private rsa key.

Install Komaci apps

Clone the Komaci repositories:

$ git clone git+ssh://gitix.iast.it/komaci/nephila-django-template && cd nephila-django-template && git checkout -t origin/master && cd -
$ git clone git+ssh://gitix.iast.it/komaci/nephila-apps && cd nephila-apps && git checkout -t origin/develop && cd -
$ git clone git+ssh://gitix.iast.it/komaci/nephila-apps-extra && cd nephila-apps-extra && git checkout -t origin/develop && cd -

nephila-fab is the only application that need to be installed in the environment (or in the current virtualenv):

$ pip install -e /path/to/nephila-fab

All the other repository doesn’t need to be installed or added to the python path: it’s responsibily of the project settings to provide that.

nephila-fab configuration

The first time you set up a Komaci project, you have to create a nephila-fab configuration file, copying it from the nephila-fab repository:

$ cp /path/to/nephila-fab/nphfab/settings/defaults.conf $HOME/.nephila-fab.conf

NOTE: Values in project section should be left as is.

This is the most important settings you should care of:

  • WWW_DIR: Path where local projects will be created. (e.g. /path/to/some/dir )
  • NPH_DIR: This is where nephila-apps resides; please insert both nephila-apps and nephila-apps-extra directories, separated by a comma, with no spaces between them. (e.g. /path/to/nephila-apps,/path/to/nephila-apps-extra )
  • TPL_DIR: Path to nephila-django-template clone (e.g. /path/to/nephila-django-template )
  • VENV_DIR: Path to virtualenvs home (e.g. /path/to/some/dir )
  • NPH_FAB: Directory where the nephila-fab is located (e.g. /path/to/some/dir )
  • PYVER: Python version (e.g. 2.7 )
  • VENV_PKG: Additional virtualenv command options
  • VENV_NAME: Set this value if you want to have a global virtualenv for all the projects and you use the no_local_venv argument to the startproject command (see below for details)

Currently there is no support for path glob extensions (such as ~). Please provide full path in the nephila-fab configuration file.

WARNING: do not include spaces after the = sign in .nephila-fab.conf!

Checking it all

As a first check you should run nph-fab -l (the script should be installed in the path).

The -l argument lists supported commands (3 at the time of writing):

$ nph-fab -l
Available commands:

    clean: Recursively clean leftovers from current directory
    git_cleanup: Clear and sync git repository removing obsolete tags and branches
    startproject: Creates a skeleton for a nephila-apps project

Creating your first project

startproject creates the basic skeleton for the project. It supports four command line arguments (separated by commas):

  • domain=domain.it: This should reflect the domain name to which the project will be deployed to in production:
  • project=www: Project name. For primary websites should be www as it will be used for dns name generation;
  • virtualenv=auto/<string>: Set this option to auto to generate a project-specific virtualenv, set to any string to use / generate a virtualenv with the given name; if omitted the current virtualenv is used;
  • www_dir: Root directory project if different from the one defined in nephila-fab.conf

The complete command line should be like this:

$ nph-fab startproject:domain=domain.it,project=www

Project creation may take some time (especially if you opted for a dedicated virtualenv). At the end of the process you should see this message:

Contratulations, project domain.it_www has been successfully created

Note: the domain.it_www part depends on the domain and project name you provided to startproject.

Project startup

You project directory should now exists in /srv/www/domain.it/www (assuming /srv/www is your WWW_DIR in $HOME/.nephila-fab.conf).

Please cd to the project directory and activate your virtualenv:

$ cd /srv/www/domain.it/www
$ workon domain.it_www

Please note that actual virtualenv name could be different if you choose to work with a global virtualenv. You are now ready to complete the configuration of your project and start developing it.

For configuration basics see README_SETTINGS.

While most defaults should be ok as is, you have to set database configuration according to your setup.

Initial configuration

To create basic configuration files:

$ fab prepare_conf_files

Then you have to export a couple variables for your env:

$ source conf/localhost/vars

To create database with proper permissions for your user (if it already exists it will be dropped):

host: fab resetdb

You now have to install all the needed packages in the virtualenv (this may take some time):

host: fab update_venv

At last, you can create the database structure, the admin user and all the basic initializations:

host: fab create_database

Multi-site

To support multi-site setups, NPH_SITES configuration must be added in each host settings files:

NPH_SITES = {
   1: {'dns':"DNS_NAME_1",'apache':"ServerAlias foo.bar"}
   2: {'dns':"DNS_NAME_2",'apache':"ServerAlias bar-foo"}
   ...
}

Each key in NPH_SITES is a dictionary containing per-site configurations; as of now, supported configuration keys are:

dns: domain to be configured in the `apache.conf` so if sites are behind a
     reverse-proxy, the internal domain should be used. This is *mandatory*.
apache: extra settings for apache.conf

Upon settings NPH_SITES variable the setup_sites task must be executed to create multisite files; this task needs to be issued after each NPH_SITES change.

Bootstrap existing project

To allow an existing project to run, first follow instruction in the prepare section.

Next step is to provide the project customization for the current environment:

Then continue with instructions in initial_config