16379: Sets grafana's admin user password through the CLI.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 21 Mar 2023 22:07:18 +0000 (19:07 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 28 Mar 2023 17:59:44 +0000 (14:59 -0300)
Although it's being correctly set on the config file, the admin credentials
are not bein honored at first server start, and so the default password
is set in the database.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

tools/salt-install/config_examples/multi_host/aws/states/grafana_admin_user.sls [new file with mode: 0644]
tools/salt-install/provision.sh

diff --git a/tools/salt-install/config_examples/multi_host/aws/states/grafana_admin_user.sls b/tools/salt-install/config_examples/multi_host/aws/states/grafana_admin_user.sls
new file mode 100644 (file)
index 0000000..6ccc8db
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+{%- set grafana_server = salt['pillar.get']('grafana', {}) %}
+
+{%- if grafana_server %}
+extra_grafana_admin_user:
+  cmd.run:
+    - name: grafana-cli admin reset-admin-password {{ grafana_server.config.security.admin_password }}
+    - require:
+      - service: grafana-service-running-service-running
+{%- endif %}
\ No newline at end of file
index edd4e5bb990f7bdf5557b7667e46601916c502f8..012e003717ef70a2ca27f1dee12b66406b7b75d3 100755 (executable)
@@ -737,6 +737,7 @@ else
         grep -q "\- grafana$" ${S_DIR}/top.sls || echo "    - grafana" >> ${S_DIR}/top.sls
         grep -q "extra.grafana_datasource" ${S_DIR}/top.sls || echo "    - extra.grafana_datasource" >> ${S_DIR}/top.sls
         grep -q "extra.grafana_dashboards" ${S_DIR}/top.sls || echo "    - extra.grafana_dashboards" >> ${S_DIR}/top.sls
+        grep -q "extra.grafana_admin_user" ${S_DIR}/top.sls || echo "    - extra.grafana_admin_user" >> ${S_DIR}/top.sls
 
         if [ "${SSL_MODE}" = "lets-encrypt" ]; then
           grep -q "letsencrypt"     ${S_DIR}/top.sls || echo "    - letsencrypt" >> ${S_DIR}/top.sls