Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Justice Playbook #65

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions apps/open-justice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Open Justice Aleph
==================

Install `ansible-role-docker`
----------------------------

```
ansible-galaxy install geerlingguy.docker
```

Post playbook
-------------
Start aleph in detached mode and set up tables

```
docker-compose up -d
docker-compose run --rm shell upgrade
```

To set up a user
----------------
Enter the Aleph shell:

```
make shell
```

Then:

```
aleph createuser --name="Alice" \
--admin \
--password=123abc \
[email protected]
```

Load sample data
---------------

```
aleph crawldir /aleph/contrib/testdata
```






103 changes: 103 additions & 0 deletions apps/open-justice/aleph.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Aleph environment configuration
#
# This file is loaded by docker-compose and transformed into a set of
# environment variables inside the containers. These are, in turn, parsed
# by aleph and used to configure the system.

# Random string:
#ALEPH_SECRET_KEY=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ALEPH_SECRET_KEY=
ALEPH_SECRET_KEY={{aleph_secret_key}}


# Visible instance name in the UI
ALEPH_APP_TITLE=Open Justice
# Name needs to be a slug, as it is used e.g. for the ES index, SQS queue name:
ALEPH_APP_NAME=open-justice
ALEPH_UI_URL=http://openjustice.openup.org.za:8080/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm we need SSL... I wonder what I did for that before - I think we shouldn't have anything sensitive in there or have people create accounts that matter until we set SSL up


# ALEPH_URL_SCHEME=https
# ALEPH_FAVICON=https://investigativedashboard.org/static/favicon.ico
# ALEPH_LOGO=http://assets.pudo.org/img/logo_bigger.png

# Other customisations
ALEPH_SAMPLE_SEARCHES=Vladimir Putin:TeliaSonera

# Set email addresses, separated by colons, that will be made admin.
# [email protected]:[email protected]

# Single-user mode disables authentication and authorization autologging in any user as admin
ALEPH_SINGLE_USER=false

# Login modalities
ALEPH_PASSWORD_LOGIN=true

# OAuth configuration
# Currently supported providers are Google, Facebook, Cognito and Azure AD OAuth
# Note that you do not need to fill out all fields in order to use it
ALEPH_OAUTH=false
ALEPH_OAUTH_KEY=
ALEPH_OAUTH_SECRET=

# You also need to provide an OpenID Connect (OIDC) configuration URL. Examples:
#
# Google:
# ALEPH_OAUTH_METADATA_URL=https://accounts.google.com/.well-known/openid-configuration
#
# KeyCloak/OCCRP:
# ALEPH_OAUTH_METADATA_URL=https://secure.occrp.org/auth/realms/general/.well-known/openid-configuration
#
# Azure:
# ALEPH_OAUTH_METADATA_URL=https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration
#
# Amazon Cognito:
# ALEPH_OAUTH_METADATA_URL=https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration

# Where and how to store the underlying files:
# ARCHIVE_TYPE=file
# ARCHIVE_PATH=/data

# Or, if 'ALEPH_ARCHIVE_TYPE' configuration is 's3':
# ARCHIVE_TYPE=s3
# ARCHIVE_BUCKET=
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# AWS_REGION=

# To use an external ElasticSearch service:
# ALEPH_ELASTICSEARCH_URI=

# To use an external Postgres service:
# ALEPH_DATABASE_URI=postgresql://<username>:<password>@<host>/<database>

# Define a different ftm entity store:
# FTM_STORE_URI=postgresql://<username>:<password>@<host>/<database>

# To run the Convert-Document service externally
# INGESTORS_CONVERT_DOCUMENT_URL=http://<convert-document>:3000/convert

# Queue mechanism
# REDIS_URL=redis://redis:6379/0

# Content options
ALEPH_OCR_DEFAULTS=eng
# ALEPH_LANGUAGES=en:de:fr:es:tr:ar ...

# Provide a valid email to send alerts from:
ALEPH_MAIL_FROM=
ALEPH_MAIL_HOST=
ALEPH_MAIL_USERNAME=
ALEPH_MAIL_PASSWORD=
ALEPH_MAIL_PORT=25
ALEPH_MAIL_TLS=true
ALEPH_MAIL_SSL=false
ALEPH_MAIL_DEBUG=false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't there sendgrid details we can reuse from open courts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be needed for password reset, at least.


# Debug mode (insecure)
ALEPH_DEBUG=false

# Read-only mode:
# ALEPH_MAINTENANCE=true

# Enable HTTP caching
# ALEPH_CACHE=true

# Configure logging
LOG_FORMAT=TEXT # TEXT or JSON
59 changes: 59 additions & 0 deletions apps/open-justice/aleph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
- hosts:
- open-justice
become: yes

roles:
- geerlingguy.docker

vars:
postgres_password: "{{ lookup('passwordstore', 'apps/open-justice/{{ env_name }}/POSTGRES')}}"
postgres_hostname: "{{ lookup('passwordstore', 'apps/open-justice/{{ env_name }}/POSTGRES subkey=hostname')}}"
postgres_username: "{{ lookup('passwordstore', 'apps/open-justice/{{ env_name }}/POSTGRES subkey=username')}}"
postgres_database: "{{ lookup('passwordstore', 'apps/open-justice/{{ env_name }}/POSTGRES subkey=database')}}"
aleph_secret_key: "{{ lookup('passwordstore', 'apps/open-justice/{{ env_name }}/ALEPH_SECRET_KEY')}}"

tasks:
- name: apt-get Update
apt:
update_cache: yes

- name: Install make
apt:
name: make
state: present

- name: Install git
apt:
name: git
state: present

- name: Map ElasticSearch Memory
become: yes
sysctl:
name: vm.max_map_count
value: 262144
state: present

- name: Clone Aleph repo
become: yes
git:
repo: https://github.com/alephdata/aleph.git
dest: /var/open-justice/aleph

- name: Copy env file
ansible.builtin.copy:
src: aleph.env
dest: /var/open-justice/aleph

- name: Add database details to env file
ansible.builtin.lineinfile:
path: /var/open-justice/aleph/aleph.env
regexp: "^ALEPH_DATABASE_URI="
line: "ALEPH_DATABASE_URI=postgresql://{{postgres_username}}:{{postgres_password}}@{{postgres_hostname}}/{{postgres_database}}"

- name: Add ALEPH_SECRET_KEY
ansible.builtin.lineinfile:
path: /var/open-justice/aleph/aleph.env
regexp: "^ALEPH_SECRET_KEY="
line: "ALEPH_SECRET_KEY={{aleph_secret_key}}"
jbothma marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 3 additions & 1 deletion inventory/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ all:
idp1-aws.openup.org.za:
pmg1-aws.pmg.org.za:
elasticsearch1-aws.pmg.org.za:
justice1-hetzner.openup.org.za:


## App groups
Expand Down Expand Up @@ -93,3 +92,6 @@ all:
hetzner1.openup.org.za:
vars:
app_domain: search.opengazettes.org.za
open-justice:
hosts:
openjustice.openup.org.za:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be justice1-hetzner.openup.org.za - we use the machine name here, so it's a bit clearer which machine we're talking about

Suggested change
openjustice.openup.org.za:
justice1-hetzner.openup.org.za: