Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set value of admin password in config not working #67

Closed
kkellner opened this issue Mar 31, 2020 · 11 comments
Closed

Set value of admin password in config not working #67

kkellner opened this issue Mar 31, 2020 · 11 comments

Comments

@kkellner
Copy link

Problem/Motivation

Trying to change the default admin user password. The following does not work as value in /etc/grafana/grafana.ini within the container still shows hassio

plugins: []
env_vars:
  - name: GF_SECURITY_ADMIN_PASSWORD
    value: test
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
log_level: info
grafana_ingress_user: myuser

Expected behavior

The admin user password is updated to the value specified.

Actual behavior

Default password remains

Steps to reproduce

Use the above config, setting the value of GF_SECURITY_ADMIN_PASSWORD and restart the container. The default password is not updated.

@addons-assistant
Copy link

👋 Thanks for opening your first issue here! If you're reporting a 🐛 bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be useful.

@kkellner
Copy link
Author

kkellner commented Apr 1, 2020

FYI, I was able to manually change password via the following, but I'm not sure the change will survive a container update. I'm assuming there is a better/cleaner way to do this.

docker exec -it $(docker ps | grep grafana | awk '{print $1}') /bin/bash
grafana-cli admin reset-admin-password mynewpassword

@sinclairpaul
Copy link
Member

The underlying issue is that the ini file takes precedence over the environment variables. The reason the password cannot be changed from the UI is to do with the configuration required to support both ingress and external access. In my view there really isn't much that can be done here, the other option would be I guess to create a new user and delete the original.

I would assume that your password reset command should be persistent, perhaps you could confirm?

@sinclairpaul
Copy link
Member

Just read your forum post, and re-read the comment, if it is persistent after a restart it will be persistent from an update.

@kkellner
Copy link
Author

kkellner commented Apr 4, 2020

OK, then it would seem this is a useable workaround to set the password. Since the readme docs say to change the default admin password, it would be a good idea to document this process until a cleaner solution comes along.

@kkellner
Copy link
Author

kkellner commented Apr 6, 2020

@sinclairpaul Can a plug-in run a program after container creation? If so, what if there was a value in the plugin config yaml like:

grafana_admin_password: somepassword

And the plug-in code ran the following command when the container started:
(where somepassword comes from the value of grafana_admin_password above

grafana-cli admin reset-admin-password somepassword

@sinclairpaul
Copy link
Member

Anything is possible, however it can be challenging as we would need to:

Confirm admin actually exists, or pass both user and password
I am assuming Grafana needs to be running, which means either starting temporarily and stopping, or having a loop somewhere.

Either that or we add in some other way to host a method of changing passwords.

At this point in time, my recommendation is to create a new user, set the password to what you want, and delete the admin user. Although not ideal, it is the only thing I can see happening in the short term.

@formadelfo
Copy link

formadelfo commented May 18, 2020

Hi,
i think i have a similar problem. I hope i'm not hijacking this question.
I am trying to change the env variabel GF_PATHS_CONFIG to a location outsite the docker image so i can change some settings. First i tried that user a sudo docker command in the terminal. But later i saw in portainer that this is not a env variable in the grafana homeassistant add-on (probably older version of grafana). The i saw that you can change env variables in the config of the add-on. But when i set config as follows:

env_vars:
  - name: GF_PATHS_CONFIG
    value: /etc/grafana/grafana2.ini

This settings seems to be ignored (just as your setting). In the log of the add-on i see, what you can see below. So first it recognizes my setting (to user grafana2.ini) and then i says it is using the original file within the docker i guess):

[14:57:11] INFO: Setting GF_PATHS_CONFIG to /etc/grafana/grafana2.ini
t=2020-05-18T14:57:11+0200 lvl=info msg="Starting Grafana" logger=server version=6.7.1 commit=ca6d08d5cb branch=HEAD compiled=2020-03-20T14:13:09+0100
t=2020-05-18T14:57:11+0200 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
t=2020-05-18T14:57:11+0200 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini

Is it not possible to change the config location to a file outsite the docker image?
If so, then how should you change settings in grafana when you are using it as an home assistant add-on...? Bit lost here...

@chapiosh
Copy link

chapiosh commented Jun 5, 2020

Same with

env_vars:
  - name: GF_DISABLE_SANITIZE_HTML
    value: 'TRUE'

Log shows:

[10:22:17] INFO: Starting Memcached...
[10:22:17] INFO: Starting Grafana...
[10:22:17] INFO: Setting GF_DISABLE_SANITIZE_HTML to TRUE

... but still is set as false once grafana runs.

@addons-assistant
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@polcape
Copy link

polcape commented Jan 7, 2021

Hi, any news on this?

How change default admin password?

Thanks

@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants