Skip to content

sthenault/saemref-formula

 
 

Repository files navigation

https://travis-ci.org/logilab/saemref-formula.svg?branch=master

saemref-formula

A saltstack formula handling installation of saem_ref.

The formula will run two web application server, one dedicated to OAIPMH request to serve /oai on port 8081 and one for other requests on port 8080.

To use them in a single port you may configure a reverse proxy, such as apache2 or nginx, on front of the instances.

Available states

Equivalent to saemref.install and saemref.config.

Installs the saemref package from logilab repositories and create an instance for user saemref.

Cubicweb config files are located in ~saemref/etc/cubicweb.d/saemref and cubicweb-ctl can be invoked as user saemref with environment variable CW_MODE=user.

The state require the installation of epel-formula and postgres-formula with version 9.4 (see pillar.example).

Only manage instance configuration files.

Create instance database with cubicweb-ctl db-create (call implicitly db-init).

WARNING: this will destroy existing database if exists.

Initialize instance database schema with cubicweb-ctl db-init.

Install and manage supervisor configuration for the saemref installation. Here is some useful commands:

  • restart instance: supervisorctl restart saemref
  • restart supervisor: systemctl restart supervisord

Requirements

If using postgres as database driver, ensure the postgres contrib package is installed on server side.

Recommended usage

Given target minion_id is 'srv'.

/srv/salt/top.sls:

base:
    'srv':
        - saemref
        - saemref.supervisor

/srv/pillar/top.sls:

base:
    'srv':
        - saemref

/srv/pillar/saemref.sls: see pillar.example

Example of reverse proxy configuration for nginx:

server {
    listen 80;
    server_name saemref.example.com;
    location / {
        proxy_pass http://srv:8080;
    }
    location /oai {
        proxy_pass http://srv:8081;
    }
}

For the first installation run salt srv state.sls db-create to create the database (WARNING: this will destroy existing database if exists).

Then run: salt srv state.highstate to finish the installation.

Upgrades

To force an upgrade to the latest version of saem-ref, connect to the minion as root, then run:

[root@minion] % supervisorctl stop all
[root@minion] % salt-call state.sls saemref.install pillar='{"upgrade": true}'
# be patient
[root@minion] % su - saemref
[saemref@minion] % . venv/bin/activate
(venv) [saemref@minion] % cubicweb-ctl upgrade saemref
# proceed to the cubicweb upgrade process
(venv) [saemref@minion] % exit
[root@minion] % supervisorctl start all

Testing

The script run-test.py can help to develop and test the formula using docker and testinfra.

The command ./run-test.py dev centos7 will build image from test/centos7.Dockerfile and span a shell in a new container with mounted volumes from the host (so you can develop formula on the host and test it in the container with salt-call).

The command ./run-test.py dev centos7 --salt is the same as above but will provision the container (eg. calling salt-call state.highstate)

The command ./run-test.py test centos7 -- test built a provisioned image (highstate) and run testinfra tests on it.

Note that you can add any parameters that testinfra (pytest) accept, for instance ./run-test.py test centos7 -- -k idempotence --pdb test.

Testing migration

Add dumps generated by cubicweb-ctl db-dump in the test/dumps directory, then:

# To test upgrade against latest public changeset of http://hg.logilab.org/master/cubes/saem_ref
./run-tests.py test centos7 -- test/test_migration.py --upgrade-revision master

# To test against any revision from http://hg.logilab.org/review/cubes/saem_ref
./run-tests.py test centos7 -- test/test_migration.py --upgrade-revision REV

About

Salt formula to install cubicweb-saem_ref

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 65.7%
  • SaltStack 31.5%
  • HTML 2.8%