Created 11-30-2016 10:29 AM
I am working on automating the installation and provisioning of clusters, which includes installing Ambari and using a Blueprint via the API. This is all working fine, but I have one more thing which I'm having trouble with, and that is changing the Ambari password during the overall provisioning process (I'm referring to my process here, not the Ambari cluster creation process). What I do NOT want is to leave newly provisioned Ambari installs sitting around with the default "admin/admin" credentials, and I also can't have a human going in to change this every time.
I've tried the REST API, but even though the call appears to execute correctly (eg, no errors are returned), the new password never takes effect.
I thought about using the ambari-admin-password-reset command via ssh, but my Ambari install (using 2.1.0) doesn't appear to have that command. I've double checked that the agent is running, and I've tried it as the root user, and in every case, it yields a "command not found" error.
I also thought about using JDBC, connecting directly to Postgres, and munging the password directly, but I'm not sure which hash algorithm Ambari uses, and/or where it stores the salt (if one is used).
If anyone can provide any advice on how to make any or all of these approaches work, it would be greatly appreciated. Right now I'm about to tear my last hair out fighting with this.
Created 11-30-2016 12:46 PM
- Suppose "joy" users password was earlier "joy123" and i want to change it to "joy321" then i would do the following.
curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "joy", "password": "joy321", "old_password": "admin"}}' http://kjss1:8080/api/v1/users/joy
NOTE: Please make sure to choose the "old_password" as the admin's users password which you used in the "-u admin:admin" command. (please do not use "joy123" as old password of that user).
Once you are able to change the password for user "joy" using above Ambari API. Then you should be able to invoke the same Rest API from your Java Code as well using rest client APIs.
Created 11-30-2016 12:46 PM
- Suppose "joy" users password was earlier "joy123" and i want to change it to "joy321" then i would do the following.
curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "joy", "password": "joy321", "old_password": "admin"}}' http://kjss1:8080/api/v1/users/joy
NOTE: Please make sure to choose the "old_password" as the admin's users password which you used in the "-u admin:admin" command. (please do not use "joy123" as old password of that user).
Once you are able to change the password for user "joy" using above Ambari API. Then you should be able to invoke the same Rest API from your Java Code as well using rest client APIs.
Created 12-01-2016 04:53 AM
Interesting, that differs slightly from the other documentation on the REST API I found here:
At any rate, I appreciate the information and I will give that a try shortly. Thanks!
Created 12-01-2016 06:00 AM
@jss - thank you, that worked. Apparently the documentation I was looking at was incorrect or outdated
or something. In either case, setting up the JSON the way you showed worked like a champ!