Skip to content

Commit

Permalink
Merge pull request #148 from genebean/change_grafana_admin_password_task
Browse files Browse the repository at this point in the history
Add a task for setting the admin user's password
  • Loading branch information
bastelfreak authored Feb 4, 2019
2 parents 025a15b + 14b9006 commit ae6ae98
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 ae6ae98

Please sign in to comment.