SCM Manager & Chef : Customizing the default admin login/password ?

483 views
Skip to first unread message

Delta

unread,
Dec 6, 2012, 6:35:28 AM12/6/12
to scmma...@googlegroups.com
First, thanks for that great tool!
I'm creating a Chef recipe to easily install scm manager on my server, and would like to know how to change the default admin user.
There's indeed a users.xml file in the SCM_Home directory, but this file is created once the server has started (which is normal): is there a way to modify the user.xml template (or similar) to have the manager using the proper credentital at first launch (and not the basic scmadmin//scmadmin) ?.
Thanks in advance for your time,
Cheers,
D

Sebastian Sdorra

unread,
Dec 7, 2012, 3:33:48 AM12/7/12
to scmma...@googlegroups.com
Hi,
I don't know chef very good. It is possible that you start scm-manager and change the password of scmadmin with a simple a api call? For example with curl:

curl -u scmadmin:scmadmin -X post --data "old-password=scmadmin&new-password=yournewpassword&confirm-password=yournewpassword" http://localhost:8080/scm/api/rest/action/change-password.xml

Sebastian


2012/12/6 Delta <del...@gmail.com>

Delta

unread,
Dec 11, 2012, 4:53:14 PM12/11/12
to scmma...@googlegroups.com
This could work, but a Chef recipe should be as indempotent as possible :  this command would work the first time, but will fail the other. Of course, one could check both the former and the new password but I was hoping to find a more elegant solution.
Maybe, there's not.
Thanks for your time anyway : much appreciated.
Cheers,
D

Alex Kiernan

unread,
Dec 11, 2012, 4:58:35 PM12/11/12
to scmma...@googlegroups.com

An API call to set the password is exactly what we do from Chef... I''ll try to remember to dig it out tomorrow.

Alex Kiernan

unread,
Dec 12, 2012, 6:25:28 AM12/12/12
to scmma...@googlegroups.com
Here's what we do just after we've installed/started SCM manager:

scm_creds = Chef::EncryptedDataBagItem.load("secrets", "scm_manager")
scmadmin_password = scm_creds["scmadmin_pasword"]

http_request "PUT /users/scmadmin" do
action :put
url "#{node["scm_manager"]["uri"]}/api/rest/users/scmadmin"
headers({"Authorization" => "Basic #{Base64.encode64("scmadmin:scmadmin")}"})
message({ :admin => true,
:displayName => "SCM Administrator",
:mail => "root@localhost",
:name => "scmadmin",
:password => scmadmin_password,
:type => "xml" })
not_if do
begin
open("#{node["scm_manager"]["uri"]}/api/rest/users/scmadmin",
:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
"Authorization" => "Basic
#{Base64.encode64("scmadmin:#{scmadmin_password}")}").status[0].to_i
== 200
rescue OpenURI::HTTPError
nil
end
end
end
--
Alex Kiernan
Reply all
Reply to author
Forward
0 new messages