Skip to main content

Deployment helpers for the statistics of the OSHA-OiRA site.

Project description

OSHA OiRA Statistics Deployment

This package contains configuration and scripts for deploying the OSHA OiRA statistics. The buildout configuration sets up a number of metabase instances to serve the statistics and generates scripts to manage them.

Setup

Quickstart

Create a buildout.cfg like this:

[buildout]
extends =
    base.cfg
    secrets.cfg

[secrets]
<= secrets-production

Run

# make

Installation / Update

One-Shot

If you're installing for the first time, you need to make sure the databases are created (see below). If you're updating an existing installation, it's usually enough to call

# make

or, equivalently,

# make all

This sets up everything in one go except for creating the databases - you may need to do this as a privileged user, and it's unnecessary to run on every update, so it's not included by default. See "Creating the Databases" for instructions.

Step-By-Step

If the one-shot setup fails for some reason or you're interested in the details, read on for a step-by-step setup.

If you're in an environment with managed secrets, decrypt the secrets file with:

# gpg -d secrets.cfg.gpg > secrets.cfg

Create a buildout.cfg that extends base.cfg and, if you're using it, secrets.cfg.

[buildout]
extends =
    base.cfg
    secrets.cfg

Make sure that there is a secrets section in your buildout.cfg and that it inherits from the correct section in secrets.cfg.gpg:

[secrets]
<= secrets-production

Otherwise set the passwords manually:

[secrets]
metabase-password = secret
ldap-password = secret

If you want to bind to a different address than localhost, set the metabase-host:

[metabase-instance]
metabase-host = oira.local

Then, as usual, run:

# bin/buildout

Alternatively, decrypting and running buildout is done by

# make buildout

Creating the Databases

During the first setup or if you get an error like

psql: FATAL:  database "xyz" does not exist

you will need to initialize the postgresql databases. Make sure

  • buildout has run sucessfully (make buildout or bin/buildout)
  • PSQL_USER (see Makefile) is set to a user who may create postgresql databases
  • your current user can use sudo to become PSQL_USER

Once you're set, run

# make create-databases

or, if you're already logged in as an appropriate user

# psql -U postgres < scripts/create-databases.sql

and then retry make all.

Usage

Getting started

If you've run make all successfully, you can skip this section.

To set up the metabase instances:

# bin/init-metabase

or

# make init-metabase

This calls bin/init-metabase-instance (see below) for all instances with the parameters specified in the corresponding buildout sections.

After that you can log in to the metabase instances with the credentials you provided in the buildout configuration.

Making changes

To make changes to the metabase content, modify the data in oira.statistics.deployment.content. It may be convenient to make changes via the UI and then get the corresponding values via the API. You can use the ipybase shell defined in devel.cfg for this purpose.

To apply the changes to the global and country instances, again run

# bin/init-metabase

init-metabase-instance

Applies settings to a single metabase instance. Sets database connection parameters and optionally creates an additional user. Run init-metabase-instance --help for arguments.

init-metabase

Initializes all metabase instances by dropping all database content and running init-metabase-instance on each of them. Does not take any parameters; buildout writes them directly into the script. If the environment variable SKIP_DB_RESTORE is set, database contents are not dropped but kept.

Changelog

1.1.2 (2026-01-21)

1.1.1 (2025-12-09)

1.1.0 (2025-04-01)

1.0.0 (2024-06-13)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oira_statistics_deployment-1.1.2.tar.gz (659.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oira_statistics_deployment-1.1.2-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file oira_statistics_deployment-1.1.2.tar.gz.

File metadata

File hashes

Hashes for oira_statistics_deployment-1.1.2.tar.gz
Algorithm Hash digest
SHA256 5f96b9ed2ab4c4938ff9a4d26494fcffad8e7e785d92f87a98688b03d628c40b
MD5 a7fa45e075f5b50581478c49fa9c103c
BLAKE2b-256 76f806597cfe703aaa05c2b250ba920baed582283152d1ffdb7e0ef365db9b59

See more details on using hashes here.

File details

Details for the file oira_statistics_deployment-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for oira_statistics_deployment-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac2d4ab644576f0dfa493dec0b3f88425e05f288bf7fef00962ecb364331675
MD5 9fc15b931f564714689074d3796a5626
BLAKE2b-256 db44e69ea0af7bdab0fb59c3bd8f0dff45e449a1f86fa83a95ba161d1fbe1a62

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page