README.rst 4.62 KB
Newer Older
Denis Laxalde's avatar
Denis Laxalde committed
1
2
3
.. image:: https://travis-ci.org/logilab/saemref-formula.svg?branch=master
    :target: https://travis-ci.org/logilab/saemref-formula

Denis Laxalde's avatar
Denis Laxalde committed
4
5
.. warning:: this project is unmaintained

Philippe Pepiot's avatar
init  
Philippe Pepiot committed
6
7
8
9
===============
saemref-formula
===============

10
A saltstack_ formula handling installation of `saem_ref`_.
11

12
13
14
15
16
17
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.

Philippe Pepiot's avatar
init  
Philippe Pepiot committed
18
19
20
21
22
23
Available states
================

.. contents::
    :local:

Philippe Pepiot's avatar
Philippe Pepiot committed
24
25
26
27
28
``saemref``
-----------

Equivalent to ``saemref.install`` and ``saemref.config``.

29
30
31
``saemref.install``
-------------------

Philippe Pepiot's avatar
Philippe Pepiot committed
32
33
34
35
36
37
38
39
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`_
Denis Laxalde's avatar
Denis Laxalde committed
40
with version 9.6 (see ``pillar.example``).
41
42
43
44

``saemref.config``
------------------

Philippe Pepiot's avatar
Philippe Pepiot committed
45
46
47
48
49
Only manage instance configuration files.

``saemref.db-create``
---------------------

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

52
53
WARNING: this will destroy existing database if exists.

54
55
56
57
``saemref.db-init``
---------------------

Initialize instance database schema with ``cubicweb-ctl db-init``.
58
59
60
61
62

``saemref.supervisor``
----------------------

Install and manage `supervisor`_ configuration for the saemref installation.
63
64
65
66
Here is some useful commands:

- restart instance: ``supervisorctl restart saemref``
- restart supervisor: ``systemctl restart supervisord``
67

Philippe Pepiot's avatar
Philippe Pepiot committed
68

69
70
71
72
73
Requirements
============

If using postgres as database driver, ensure the `postgres contrib`_ package is
installed on server side.
Philippe Pepiot's avatar
Philippe Pepiot committed
74

75
76
Recommended usage
=================
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

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 <test/pillar/example.sls>`_


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.
116

117
118
119
120
121
122
Upgrades
========

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

123
124
125
    [root@minion] % salt-call state.sls saemref.upgrade

If upgrade process fails, a backup is created in `/home/saemref/etc/cubicweb.d/saemref/backup`
126

127
128
129
130
131
132
Testing
=======

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

Sylvain Thenault's avatar
Sylvain Thenault committed
133
134
The command ``./run-test.py dev centos7`` will build image from
``test/centos7.Dockerfile`` and span a shell in a new container with mounted
135
136
137
volumes from the host (so you can develop formula on the host and test it in
the container with ``salt-call``).

Sylvain Thenault's avatar
Sylvain Thenault committed
138
The command ``./run-test.py dev centos7 --salt`` is the same as above but will
139
140
provision the container (eg. calling ``salt-call state.highstate``)

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

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

Philippe Pepiot's avatar
init  
Philippe Pepiot committed
147

Philippe Pepiot's avatar
Philippe Pepiot committed
148
149
150
151
152
153
154
155
156
157
158
159
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


160
.. _saltstack: https://saltstack.com/
161
162
163
164
.. _saem_ref: https://www.cubicweb.org/project/cubicweb-saem_ref
.. _supervisor: http://supervisord.org
.. _docker: https://www.docker.com/
.. _testinfra: https://testinfra.readthedocs.org/
Philippe Pepiot's avatar
Philippe Pepiot committed
165
166
.. _epel-formula: https://github.com/saltstack-formulas/epel-formula
.. _postgres-formula: https://github.com/saltstack-formulas/postgres-formula
167
.. _postgres contrib: https://www.postgresql.org/docs/current/static/contrib.html