Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Reset grafana password via grafana-cli #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

combor
Copy link

@combor combor commented Feb 23, 2017

What

The grafana-cli admin command was introduced in v 4.1 and allows to
change admin user password via cli.

This will allow to set new password in the manifest and rotate it during deployment.

Unfortunatelly grafana-cli is a little bit silly now and can only read config from $WORKING_DIR/conf/defaults.ini and as we have grfana.db in /var/vcap/store/grafana we need to point it there somehow.

NOTE This requires grafana 4.1 so version bump is necessary.

How to test

  • Deploy grafana and check if you can login to UI as admin
  • change password in the manifest
  • redeploy and verify that admin password to UI has been changed

The `grafana-cli admin` command was introduced in v 4.1 and allows to
change admin user password via cli.

This will allow us to set new password in the manifest and rotate it
during deployment.

Unfortunatelly `grafana-cli` is a little bit silly now and can only read
config from `$WORKING_DIR/conf/defaults.ini` and as we have grfana.db in
`/var/vcap/store/grafana` we need to point it to it somehow.
@dcarley
Copy link

dcarley commented Mar 8, 2017

NOTE This requires grafana 4.1 so version bump is necessary.

Now covered by #22.

cd $(dirname $0)/..
mkdir conf
ln -s $(pwd)/config/config.ini $(pwd)/conf/defaults.ini
/var/vcap/packages/grafana/bin/grafana-cli admin reset-admin-password <%= p("grafana.admin_password") %>
Copy link
Owner

Choose a reason for hiding this comment

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

This should probably be escaped using Shellwords.shellescape - passwords can have funny characters in them.

@@ -5,3 +5,11 @@ $(dirname $0)/create-update-datasources

echo "[$(date)] Calling 'create-update-dashboards' ..."
$(dirname $0)/create-update-dashboards

echo "[$(date)] Updating password for admin user"
(
Copy link
Owner

Choose a reason for hiding this comment

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

Using a subshell here will prevent a failure within from making the outer script fail. Is that intentional?

May want to use pushd and popd instead, if not.

Copy link
Owner

@vito vito left a comment

Choose a reason for hiding this comment

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

(should have requested changes but have forgot, and can't leave this blank)

@toddboom
Copy link
Collaborator

toddboom commented Apr 5, 2019

@combor Are you still interested in getting this cleaned up? If not, I can try to knock out the requested changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants