- 
      
- 
        Save munteanulc/0b4e129a0bcff2aa0e7f83bde50f95a4 to your computer and use it in GitHub Desktop. 
Revisions
- 
        dnozay revised this gist May 14, 2015 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,8 +39,38 @@ appsettings.signin_enabled = true appsettings.save ``` # Pre-populate users I have found that you can just post the info with your admin token: * https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md * http://doc.gitlab.com/ce/api/README.html ```python import requests headers = { 'PRIVATE-TOKEN' : 'insert-token-here' } data = { 'email': email, 'extern_uid': dn, "provider": "ldapmain", "name": name, "username": username, 'password': '1234567890', "confirm": False, } requests.post('https://gitlab.example.com/api/v3/users/', data, headers=headers) ``` I get the email, dn, name, username from ldap by using python-ldap; I use a filter to only match engineers. The password is required, but you can use a dummy value that matches the security parameters (min 8 characters ...etc) # Pre-confirm users In case you missed to add `confirm=false` when creating users. ```bash gitlab-rails console production ``` 
- 
        dnozay revised this gist May 14, 2015 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,4 +37,20 @@ user.save appsettings = ApplicationSetting.find_by(signin_enabled: false) appsettings.signin_enabled = true appsettings.save ``` # Pre-confirm users ```bash gitlab-rails console production ``` then ```ruby for user in User.where(confirmed_at: nil) do user.confirmed_at = Time.now user.confirmation_token = nil user.save! end ``` 
- 
        dnozay revised this gist Mar 5, 2015 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ # Reset root/admin password Lost the root/admin password? You can reset it using the command-line. @@ -30,3 +29,12 @@ user.password_confirmation = 'secret_pass' user.save ``` # Re-enable standard login ```ruby # locate application settings # ApplicationSetting.find_each appsettings = ApplicationSetting.find_by(signin_enabled: false) appsettings.signin_enabled = true appsettings.save ``` 
- 
        dnozay created this gist Mar 5, 2015 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ # Reset root/admin password Lost the root/admin password? You can reset it using the command-line. Recipe adapted from [gitlab issue #308](https://gitlab.com/gitlab-org/omnibus-gitlab/issues/308). ```bash # start the console sudo gitlab-rails console ``` Then in the ruby interpreter: ```ruby # find the user: # user = User.find_by(email: "[email protected]") # user = User.find_by(username: "root") # user = User.find_by(name: "Administrator") # user = User.find_by(admin: true) user = User.find_by(username: "root") # change the password # or use the ask function from 'highline/import' user.password = 'secret_pass' user.password_confirmation = 'secret_pass' # and save user.save ```