Skip to content

Commit ef9a99e

Browse files
authored
Enable deployment of engine and federation-api on a single server (#41)
2 parents 5d2609c + c3200a0 commit ef9a99e

File tree

70 files changed

+546
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+546
-756
lines changed

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,32 @@
22

33
All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5-
## Unreleased
5+
## Unreleased [major]
6+
7+
_Full changeset and discussions: [#41](https://github.com/OpenTermsArchive/deployment/pull/41)._
8+
9+
> Development of this release was supported by the [French Ministry for Foreign Affairs](https://www.diplomatie.gouv.fr/fr/politique-etrangere-de-la-france/diplomatie-numerique/) through its ministerial [State Startups incubator](https://beta.gouv.fr/startups/open-terms-archive.html) under the aegis of the Ambassador for Digital Affairs.
10+
11+
### Changed
12+
13+
- **Breaking:** Replace all playbooks with a single `deploy` playbook; update your scripts by using `ansible-playbook opentermsarchive.deployment.deploy` and use [tags to refine execution](./README.md#refining-playbook-execution)
14+
- **Breaking:** Change the `federation-api` deployment process to be a dependency of the source repository
15+
- **Breaking:** Require `engine>=2` and `federation-api>=v2`
16+
- **Breaking:** Make `ota_source_repository` variable mandatory
17+
- **Breaking:** Define environment variables in a `.env` file instead of in inventory variables; move `ota_engine_github_token`, `ota_engine_smtp_password`, `ota_engine_sendinblue_api_key`, and `ota_federated_api_smtp_password` to a `.env` file placed next to the inventory file and rename them according to the new naming conventions in `engine` v2 and `federation-api` v2
18+
- **Breaking:** Rename `ota_engine_declarations_branch` to `ota_source_repository_branch`
19+
- **Breaking:** Rename `ota_engine_declarations_directory` to `ota_directory`
20+
- **Breaking:** Extract the PM2 config file `pm2.config.cjs`; provide this file next to the inventory file
21+
- **Breaking:** Remove the `ota_engine_restart_delay` variable; define this setting directly in the `pm2.config.cjs`
22+
- **Breaking:** Remove the `ota_engine_github_bot_private_key` variable in favor of the `github-bot-private-key` file; define the GitHub SSH private key in the `github-bot-private-key`
23+
24+
### Removed
25+
26+
- **Breaking:** Remove `ota_reverse_proxy_federated_api_path` config; define this path in your `config/production.json` under the key `@opentermsarchive/federation-api: { basePath: "" }`
27+
- **Breaking:** Remove `ota_reverse_proxy_engine_path` config; define this path in your `config/production.json` under the key `@opentermsarchive/engine: { collection-api: { basePath: "" } }`
28+
- **Breaking:** Remove obsolete `ota_engine_config_path`, `ota_federated_api_branch`, `ota_federated_api_directory`, and `ota_federated_api_repo` configs
29+
- **Breaking:** Remove obsolete `update-declarations` tag
30+
631

732
## 1.2.1 - 2024-05-22
833

README.md

Lines changed: 78 additions & 147 deletions
Large diffs are not rendered by default.

playbooks/deploy.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
- name: Deploy Open Terms Archive applications
3+
hosts: all
4+
tasks:
5+
- name: Load OTA applications configs
6+
ansible.builtin.include_role:
7+
name: ota/apps
8+
public: true # ensure that the role's variables and defaults are accessible to the play
9+
vars:
10+
ota_apps_read_config_only: true
11+
12+
- name: Set required variables
13+
set_fact:
14+
chromium_required: "{{ ota_apps_config['@opentermsarchive/engine'] is defined }}"
15+
# Skip Debian 11 with ARM architecture as it is not currently supported by MongoDB; see https://www.mongodb.com/docs/manual/installation/#supported-platforms
16+
mongo_required:
17+
"{{
18+
(ansible_distribution != 'Debian' or (ansible_distribution == 'Debian' and ansible_facts['architecture'] != 'aarch64'))
19+
and (
20+
(ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.type is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.type == 'mongo')
21+
or
22+
(ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.type is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.type == 'mongo')
23+
) | bool
24+
}}"
25+
26+
snapshots_repository: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.repository is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.repository }}"
27+
snapshots_path: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.path is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.path }}"
28+
29+
versions_repository: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.repository is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.repository }}"
30+
versions_path: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.path is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.path }}"
31+
32+
collection_api_basePath: "{{ ota_apps_config['@opentermsarchive/engine']['collection-api'].basePath is defined and ota_apps_config['@opentermsarchive/engine']['collection-api'].basePath }}"
33+
collection_api_port: "{{ ota_apps_config['@opentermsarchive/engine']['collection-api'].port is defined and ota_apps_config['@opentermsarchive/engine']['collection-api'].port }}"
34+
35+
federation_api_basePath: "{{ ota_apps_config['@opentermsarchive/federation-api'].basePath is defined and ota_apps_config['@opentermsarchive/federation-api'].basePath }}"
36+
federation_api_port: "{{ ota_apps_config['@opentermsarchive/federation-api'].port is defined and ota_apps_config['@opentermsarchive/federation-api'].port }}"
37+
38+
- name: Install infrastructure
39+
become: true
40+
tags: [infrastructure]
41+
block:
42+
- name: Install Node
43+
ansible.builtin.include_role:
44+
name: node
45+
46+
- name: Install PM2
47+
ansible.builtin.include_role:
48+
name: pm2/install
49+
50+
- name: Install Chromium
51+
ansible.builtin.include_role:
52+
name: chromium
53+
when: chromium_required
54+
55+
- name: Install Nginx
56+
ansible.builtin.include_role:
57+
name: nginx/install
58+
59+
- name: Install Mongo
60+
ansible.builtin.include_role:
61+
name: mongo/install
62+
when:
63+
- mongo_required
64+
65+
- name: Configure Mongo
66+
ansible.builtin.include_role:
67+
name: mongo/configure
68+
apply:
69+
become: true
70+
when:
71+
- mongo_required
72+
73+
- name: Setup Git-based versions database
74+
ansible.builtin.include_role:
75+
name: ota/git-database
76+
vars:
77+
ota_git_database_repository: "{{ versions_repository }}"
78+
ota_git_database_directory: "{{ versions_path }}"
79+
ota_git_database_branch: main
80+
when:
81+
- versions_repository and versions_path
82+
83+
- name: Setup Git-based snapshots database
84+
ansible.builtin.include_role:
85+
name: ota/git-database
86+
vars:
87+
ota_git_database_repository: "{{ snapshots_repository }}"
88+
ota_git_database_directory: "{{ snapshots_path }}"
89+
ota_git_database_branch: main
90+
when:
91+
- snapshots_repository and snapshots_path
92+
93+
- name: Setup OTA applications
94+
ansible.builtin.include_role:
95+
name: ota/apps
96+
97+
- name: Start OTA applications
98+
ansible.builtin.include_role:
99+
name: pm2/manage
100+
101+
- name: Configure NGINX
102+
ansible.builtin.include_role:
103+
name: nginx/configure
104+
apply:
105+
become: true
106+
vars:
107+
ota_nginx_config_template: ./templates/nginx.conf.j2
108+
ota_nginx_reverse_proxy_config_template: ./templates/nginx-reverse-proxy-conf.j2

playbooks/engine/all.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

playbooks/engine/application.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

playbooks/engine/infrastructure.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

playbooks/engine_and_federated_api/all.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

playbooks/engine_and_federated_api/application.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

playbooks/engine_and_federated_api/infrastructure.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

playbooks/federated_api/all.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)