title: gitlab initial root password
body: <p>Im trying to do an automated deployment of gitlab that has everything pre-configured. I need to specify an initial root password so first-time logins are not prompted with the password reset screen. I see the omnibus config option in the template: <a href="https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L509" rel="noreferrer">https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L509</a></p>
  
  <pre><code>506 #### Change the initial default admin password and shared runner registration tokens.
  507 ####! **Only applicable on initial setup, changing these settings after database
  508 ####!   is created and seeded won't yield any change.**
  509 # gitlab_rails['initial_root_password'] = "password"
  </code></pre>
  
  <p>However, as the documentation says, this option will not take affect after installation. So, using <code>gitlab-ctl reconfigure</code> does not deploy these changes, as I have tested.</p>
  
  <p>When I try the solution from this <a href="https://stackoverflow.com/a/51061963/3865495">this post</a>:</p>
  
  <pre><code>$ sudo gitlab-rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD="Pa$$w0rd!" GITLAB_ROOT_EMAIL="gitlab@domain.com" DISABLE_DATABASE_ENVIRONMENT_CHECK=1
  This will create the necessary database tables and seed the database.
  You will lose any previous data stored in the database.
  Do you want to continue (yes/no)? yes
  
  PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
  DETAIL:  There are 10 other sessions using the database.
  : DROP DATABASE IF EXISTS "gitlabhq_production"
  Couldn't drop database 'gitlabhq_production'
  rake aborted!
  ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
  DETAIL:  There are 10 other sessions using the database.
  : DROP DATABASE IF EXISTS "gitlabhq_production"
  /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:33:in `setup_db'
  /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:5:in `block (2 levels) in &lt;top (required)&gt;'
  /opt/gitlab/embedded/bin/bundle:23:in `load'
  /opt/gitlab/embedded/bin/bundle:23:in `&lt;main&gt;'
  
  Caused by:
  PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
  DETAIL:  There are 10 other sessions using the database.
  /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:33:in `setup_db'
  /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:5:in `block (2 levels) in &lt;top (required)&gt;'
  /opt/gitlab/embedded/bin/bundle:23:in `load'
  /opt/gitlab/embedded/bin/bundle:23:in `&lt;main&gt;'
  Tasks: TOP =&gt; db:drop:_unsafe
  (See full trace by running task with --trace)
  </code></pre>
  
  <p>When I try to stop gitlab so no users are accessing it with <code>gitlab-ctl stop</code>, it fails with the following error:</p>
  
  <pre><code>$ sudo gitlab-rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD="Pa$$w0rd!" GITLAB_ROOT_EMAIL="gitlab@domain.com" DISABLE_DATABASE_ENVIRONMENT_CHECK=1
  rake aborted!
  PG::ConnectionBad: could not connect to server: No such file or directory
          Is the server running locally and accepting
          connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
  /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb:261:in `load_license'
  /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb:250:in `current'
  /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb:254:in `feature_available?'
  /opt/gitlab/embedded/service/gitlab-rails/ee/lib/ee/gitlab/auth/ldap/config.rb:19:in `_available_servers'
  /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/auth/ldap/config.rb:39:in `available_servers'
  /opt/gitlab/embedded/service/gitlab-rails/config/initializers/omniauth.rb:3:in `&lt;module:Strategies&gt;'
  /opt/gitlab/embedded/service/gitlab-rails/config/initializers/omniauth.rb:2:in `&lt;top (required)&gt;'
  /opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:6:in `&lt;top (required)&gt;'
  /opt/gitlab/embedded/bin/bundle:23:in `load'
  /opt/gitlab/embedded/bin/bundle:23:in `&lt;main&gt;'
  Tasks: TOP =&gt; gitlab:setup =&gt; gitlab_environment =&gt; environment
  (See full trace by running task with --trace)
  
  </code></pre>
  
  <p>How do I set an initial root password for gitlab with the omnibus install?</p>