From 36581a726f057d8caf675a813e000ca0f9306893 Mon Sep 17 00:00:00 2001
From: Antoine Schildknecht <antoine.schildknecht@ubicast.eu>
Date: Wed, 3 Jun 2020 15:26:40 +0000
Subject: [PATCH] Add doc for HA deployment

---
 doc/deploy-ha.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 doc/deploy-ha.md

diff --git a/doc/deploy-ha.md b/doc/deploy-ha.md
new file mode 100644
index 00000000..ed9bcd4b
--- /dev/null
+++ b/doc/deploy-ha.md
@@ -0,0 +1,84 @@
+# HA deployment
+
+## Prerequisites
+
+* root access on the computer used for the deployment, with the following :
+  * SSH access to every computers of the deployment scope
+  * `git` package
+* An account on [mirismanager](https://mirismanager.ubicast.eu)
+
+## Configuration on miris manager
+
+Go to the [miris manager](https://mirismanager.ubicast.eu/) web page corresponding to the mediaserver.
+Go to the ERP webpage of the server.
+
+In the `Mot de passe` tab clic on `Nouvel identifiant` and fill the fields as following (keep default value if the field is not mentionned) :
+```sh
+Type d'identifiant : Database
+Mot de passe : <Générer un mot de passe complexe avec le bouton associé>
+Avancé : <Cocher>
+Lien : localhost:54321
+```
+
+Clic on `Envoyer`
+
+You can check in `Exporter tous les identifiants > envsetup` that the `DB_PORT='54321'` line is showing.
+
+## Installation scripts preparation
+
+On the computer used for the deployment, go to the `/root` folder.
+
+Get the latest deployment scripts :
+```sh
+cd /root
+git clone https://git.ubicast.net/mediaserver/envsetup
+cd envsetup
+```
+
+Configure the environment as described [here](./install.md)
+
+## HA inventory configuration
+
+Make a copy of the example inventory :
+```sh
+cp -r inventories/exemple-ha inventories/<client-ha>
+```
+Configure the following :
+* `inventories/<client-ha>/hosts` : change the IP addresses according to the real deployment environment
+* `inventories/<client-ha>/group_vars/all.yml` : adapt the IP addresses following the `server pgX` and `server msX` statements
+* `inventories/<client-ha>/host_vars/*.yml` : in every file put the skyreach API key in place of the `changeme` statement
+
+## Verification
+
+Before deploying, check that every computer is accessible from ansible with the following command :
+```sh
+ansible -i inventories/<client-ha> -m ping all
+```
+If a computer response is `UNREACHABLE`, check if he is powered on and accessible through SSH
+
+## Deployment
+
+You can deploy the environment with the following command :
+```sh
+make deploy-ha i=inventories/<client-ha>
+```
+
+# Known error (patched in the next skyreach release)
+
+If the following error is encountered during the deployment :
+```sh
+[...]
+Action "init" failed:
+Database creation failed. The following command exited with code 2:
+PGPASSWORD='*****' psql -w -q -A -h localhost -p 5432 -U postgres -c "CREATE USER skyreach WITH PASSWORD '******';"
+psql: FATAL:  password authentication failed for user "postgres"
+FATAL:  password authentication failed for user "postgres"
+[...]
+```
+It may be linked to a current skyreach bug (a patch is waiting to be deployed at the time of writing) causing it not to take the DB_PORT from mirismanager configuration in account (5432 instead of 54321 for HA).
+
+You can edit the skyreach configuration manual with the following command :
+```sh
+ansible -i inventories/<client-ha> -m shell -a "sed -i \"s/'PORT': .*/'PORT': '54321'/g\" /home/skyreach/htdocs/skyreach_site/settings_override.py" ms1
+```
+and then deploy again as described in the previous section
-- 
GitLab