Skip to content

Commit

Permalink
Add a task for setting the admin user's password
Browse files Browse the repository at this point in the history
This task will allow you to change the admin user's password without
having to remember the curl command for the Grafana API.
  • Loading branch information
genebean committed Jan 4, 2019
1 parent 92965e1 commit 14b9006
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -17,6 +17,7 @@
1. [Usage](#usage)
* [Classes and Defined Types](#classes-and-defined-types)
* [Advanced usage](#advanced-usage)
1. [Tasks](#tasks)
1. [Limitations](#limitations)
1. [Copyright and License](#copyright-and-license)

Expand Down Expand Up @@ -864,6 +865,20 @@ the filesystem of the puppetserver/master. Thus you may specify a
local directory with grafana dashboards you wish to provision into
grafana.

## Tasks

### `change_grafana_admin_password`

`old_password`: the old admin password

`new_password`: the password you want to use for the admin user

`uri`: `http` or `https`

`port`: the port Grafana runs on locally

This task can be used to change the password for the admin user in grafana

## Limitations

This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docker'
Expand Down
25 changes: 25 additions & 0 deletions tasks/change_grafana_admin_password.json
@@ -0,0 +1,25 @@
{
"puppet_task_version": 1,
"supports_noop": false,
"description": "Change the Grafana admin user's password",
"parameters": {
"old_password": {
"description": "The old admin password",
"type": "Optional[String[1]]",
"sensitive": true
},
"new_password": {
"description": "The new admin password",
"type": "Optional[String[1]]",
"sensitive": true
},
"uri": {
"description": "http or https",
"type": "Enum['http','https']"
},
"port": {
"description": "The port Grafana is running on",
"type": "Integer"
}
}
}
9 changes: 9 additions & 0 deletions tasks/change_grafana_admin_password.sh
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
payload="{
\"oldPassword\": \"$PT_old_password\",
\"newPassword\": \"$PT_new_password\",
\"confirmNew\": \"$PT_new_password\"
}"

cmd="/usr/bin/curl -X PUT -H 'Content-Type: application/json' -d '$payload' '$PT_uri://admin:$PT_old_password@localhost:$PT_port/api/user/password'"
eval "$cmd"

0 comments on commit 14b9006

Please sign in to comment.