Skip to content

Commit

Permalink
Merge branch 'main' into traduction
Browse files Browse the repository at this point in the history
  • Loading branch information
elisepoupette2 authored Mar 13, 2024
2 parents 97f3326 + bf59cd5 commit b1407f4
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 25 deletions.
30 changes: 30 additions & 0 deletions docs/src/compositions/opensearch-mono.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,33 @@ curl -k -u admin:admin https://localhost:9200/

`-k` demande d'ignorer les certificats, et `-u admin:admin` permet
de s'authentifier et d'avoir tous les droits.

## Utiliser OpenSearch Dashboards

OpenSearch Dashboards écoute sur le port `5601`. Un tunnel est
automatiquement mis en place avec Docker, mais en VM ou sur un
serveur, il faut [faire un tunnel SSH](../nxc/cheatsheet.md#port-forwarding).

On peut ensuite ouvrir [`http://localhost:5601/`](http://localhost:5601)
dans un navigateur.

On peut se connecter avec l'user `admin` et le mot de passe `admin`.

À la première connection, il sera demandé de choisir un « _tenant_ ».
Il faut choisir « Private » pour avoir accès au Dashboard par défaut.
Si jamais vous avez choisi un autre _tenant_ et que vous voulez changer,
vous pouvez le faire à tout moment en cliquant sur votre avatar en haut
à droite, puis sur « Switch tenants ».

Un dashboard par défaut (assez minimaliste) est disponible.
Pour le voir, cliquer sur « Visualize & analyze » (au centre de
l'écran d'accueil), puis « Dashboard » puis « Vector data ».

Il est possible de modifier ce Dashboard et d'y ajouter des
visualisations. Pour sauvegarder les changements et les
conserver même si la composition est relancée (ce qui efface
toutes les données du système), il faut exporter les données.
Pour celà, aller dans l'onglet « Manage » (en haut à droite
de la page d'accueil), puis « Saved objects » (menu de gauche)
puis exporter tous les objets (« Export X objects », en haut à droite).
Le fichier `export.ndjson` doit être enregistré dans `opensearch-mono/export.ndjson`.
61 changes: 37 additions & 24 deletions opensearch-mono/composition.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ in
{
imports = [ ../opensearch-dashboards.nix ../colmet.nix ];

security.pki.certificateFiles = [ "${pkgs.opensearch-root-cert}/cert.pem" ];
environment.noXlibs = false;
environment.systemPackages = with pkgs; [ opensearch-fixed jq ] ++ (if enable-vector then [ vector ] else []);
environment.systemPackages = with pkgs; [ opensearch-fixed jq opensearch-root-cert ] ++ (if enable-vector then [ vector ] else []);

systemd.services.opensearch.serviceConfig.ExecStartPre = [
"${pkgs.writeShellScript
Expand All @@ -32,29 +33,20 @@ in
-storepass '${keystore-password}' \
-dname CN=localhost \
-keyalg RSA \
-sigalg SHA256withRSA \
-keystore /var/lib/opensearch/config/ssl-keystore.p12 \
-validity 36500
# Create a truststore with our own certificate
# export the cert from the keystore
cert_file=$(${pkgs.coreutils}/bin/mktemp)
${pkgs.jre_headless}/bin/keytool \
-export \
-alias opensearch \
-storepass '${keystore-password}' \
-keystore /var/lib/opensearch/config/ssl-keystore.p12 \
-file $cert_file
${pkgs.jre_headless}/bin/keytool -certreq -alias opensearch -keystore /var/lib/opensearch/config/ssl-keystore.p12 -file /var/lib/opensearch/config/newkey.csr -storepass '${keystore-password}'
${pkgs.jre_headless}/bin/keytool -gencert -infile /var/lib/opensearch/config/newkey.csr -outfile /var/lib/opensearch/config/newkey.crt -alias opensearch-root-cert -keystore ${pkgs.opensearch-root-cert}/keystore.p12 -storepass '${keystore-password}'
${pkgs.jre_headless}/bin/keytool -importcert -file ${pkgs.opensearch-root-cert}/root.crt -keystore /var/lib/opensearch/config/ssl-keystore.p12 -alias opensearch-root-cert -storepass '${keystore-password}' -noprompt
${pkgs.jre_headless}/bin/keytool -importcert -file /var/lib/opensearch/config/newkey.crt -keystore /var/lib/opensearch/config/ssl-keystore.p12 -alias opensearch -storepass '${keystore-password}' -noprompt
cp ${pkgs.opensearch-root-cert}/truststore.p12 /var/lib/opensearch/config/ssl-truststore.p12
# import it
${pkgs.jre_headless}/bin/keytool \
-import \
-noprompt \
-alias opensearch-cert \
-storepass '${truststore-password}' \
-keystore /var/lib/opensearch/config/ssl-truststore.p12 \
-file $cert_file
${pkgs.coreutils}/bin/rm $cert_file
''}"
];
systemd.services.opensearch.serviceConfig.Restart = lib.mkForce "no";
Expand All @@ -71,6 +63,7 @@ in
/var/lib/opensearch/plugins/opensearch-security/tools/securityadmin.sh \
-ks /var/lib/opensearch/config/ssl-keystore.p12 \
-kspass '${keystore-password}' \
-ksalias opensearch \
-ts /var/lib/opensearch/config/ssl-truststore.p12 \
-tspass '${truststore-password}' \
-cd /var/lib/opensearch/config/opensearch-security
Expand All @@ -81,20 +74,22 @@ in
enable = true;
package = opensearch-fixed;
settings."plugins.security.disabled" = false;
settings."plugins.security.ssl.transport.keystore_filepath" = "ssl-keystore.p12";
settings."plugins.security.ssl.transport.keystore_type" = "PKCS12";
settings."plugins.security.ssl.transport.keystore_password" = keystore-password;
settings."plugins.security.ssl.transport.truststore_filepath" = "ssl-truststore.p12";
settings."plugins.security.ssl.transport.truststore_filepath" = "/var/lib/opensearch/config/ssl-truststore.p12";
settings."plugins.security.ssl.transport.truststore_type" = "PKCS12";
settings."plugins.security.ssl.transport.truststore_password" = truststore-password;
settings."plugins.security.ssl.http.enabled" = true;
settings."plugins.security.ssl.http.keystore_filepath" = "ssl-keystore.p12";
settings."plugins.security.ssl.http.keystore_filepath" = "/var/lib/opensearch/config/ssl-keystore.p12";
settings."plugins.security.ssl.http.keystore_type" = "PKCS12";
settings."plugins.security.ssl.http.keystore_password" = keystore-password;
settings."plugins.security.ssl.http.truststore_filepath" = "ssl-truststore.p12";
settings."plugins.security.ssl.http.truststore_filepath" = "/var/lib/opensearch/config/ssl-truststore.p12";
settings."plugins.security.ssl.http.truststore_type" = "PKCS12";
settings."plugins.security.ssl.http.truststore_password" = truststore-password;
settings."plugins.security.authcz.admin_dn" = [ "CN=localhost" ];
settings."plugins.security.ssl.transport.keystore_alias" = "opensearch";
settings."plugins.security.ssl.transport.keystore_filepath" = "/var/lib/opensearch/config/ssl-keystore.p12";

# Additional Java options configuration (only for the "opensearch" service)
# Virtual machines created with `nxc build -f vm` only have 1MB of RAM
# By default, the JVM asks for more memory than that and cannot start
Expand Down Expand Up @@ -142,6 +137,24 @@ in
};
};
services.opensearch-dashboards.enable = true;
systemd.services.opensearch-dashboards.serviceConfig.ExecStartPost = [
"${pkgs.writeShellScript
"configure-graphs"
''
while ! ${pkgs.curl}/bin/curl --fail http://localhost:5601/; do
sleep 1
done
${pkgs.curl}/bin/curl -X POST \
-u admin:admin \
-H "osd-xsrf: osd-fetch" \
-H 'osd-version: 2.11.1' \
-H 'Origin: http://localhost:5601' \
'http://localhost:5601/api/saved_objects/_import?overwrite=true' \
--form file=@${./export.ndjson}
''}"
];

services.colmet-collector.enable = enable-colmet;
services.colmet-node.enable = enable-colmet;

Expand Down
Loading

0 comments on commit b1407f4

Please sign in to comment.