Error installing gitlab CE on Ubuntu 20.04

Error installing gitlab CE on ubuntu 20.04

Output of sudo EXTERNAL_URL="https://gitlab.<mydomain>.com" apt-get install gitlab-ce:

****************
Recipe: gitlab::database_migrations
  * bash[migrate gitlab-rails database] action run
    [execute] 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/lib/tasks/gitlab/db.rake:58:in `block (3 levels) in <top (required)>'
              /opt/gitlab/embedded/bin/bundle:23:in `load'
              /opt/gitlab/embedded/bin/bundle:23:in `<main>'
              Tasks: TOP => gitlab:db:configure
              (See full trace by running task with --trace)

    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20201109-32224-mrmt1w" ----
    STDOUT: 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/lib/tasks/gitlab/db.rake:58:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'
    Tasks: TOP => gitlab:db:configure
    (See full trace by running task with --trace)
    STDERR:
    ---- End output of "bash"  "/tmp/chef-script20201109-32224-mrmt1w" ----
    Ran "bash"  "/tmp/chef-script20201109-32224-mrmt1w" returned 1

    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb

     55: bash "migrate gitlab-rails database" do
     56:   code <<-EOH
     57:     set -e
     58:     log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"
     59:     umask 077
     60:     /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
     61:     STATUS=${PIPESTATUS[0]}
     62:     chown #{account_helper.gitlab_user}:#{account_helper.gitlab_group} ${log_file}
     63:     echo $STATUS > #{db_migrate_status_file}
     64:     exit $STATUS
     65:   EOH
     66:   environment env_variables unless env_variables.empty?
     67:   notifies :run, "execute[clear the gitlab-rails cache]", :immediately
     68:   dependent_services.each do |svc|
     69:     notifies :restart, svc, :immediately
     70:   end
     71:   not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
     72:   only_if { node['gitlab']['gitlab-rails']['auto_migrate'] }
     73: end

    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:55:in `from_file'

    bash("migrate gitlab-rails database") do
      action [:run]
      default_guard_interpreter :default
      command nil
      backup 5
      interpreter "bash"
      declared_type :bash
      cookbook_name "gitlab"
      recipe_name "database_migrations"
      code "    set -e\n    log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log\"\n    umask 077\n    /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}\n    STATUS=${PIPESTATUS[0]}\n    chown git:git ${log_file}\n    echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-eaa194f15e6\n    exit $STATUS\n"
      domain nil
      user nil
      not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-eaa194f15e6) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-eaa194f15e6 | grep -Fx 0)"
      only_if { #code block }
    end

    System Info:
    ------------
    chef_version=15.14.0
    platform=ubuntu
    platform_version=18.04
    ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
    program_name=/opt/gitlab/embedded/bin/chef-client
    executable=/opt/gitlab/embedded/bin/chef-client
Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20201109-369-183k90w" ----
STDOUT: 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/lib/tasks/gitlab/db.rake:58:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR:
---- End output of "bash"  "/tmp/chef-script20201109-369-183k90w" ----
Ran "bash"  "/tmp/chef-script20201109-369-183k90w" returned 1

Running handlers complete
Chef Infra Client failed. 6 resources updated in 02 minutes 06 seconds
***************

Same problem with Ubuntu 18.04.
Server is a DO droplet 8 core with 32 GB ram.

I expect this to be the problem. If you wish it to carry across to root, try sudo -E instead. Alternatively, better way is install package, and then edit /etc/gitlab/gitlab.rb and set external URL and issue gitlab-ctl reconfigure after this. That way it doesn’t need to rely on sudo passing variable to root which it’s not doing right now without the -E flag. Try:

sudo -E EXTERNAL_URL="https://gitlab.<mydomain>.com" apt-get install gitlab-ce

Hi Ian,

Thanks for your prompt reply.

I will try as you suggest. However, I have previously run the command with out the EXTERNAL_URL var.
The gitlab.rb con file already exists with the external_url setting set properly.

I was able to install 13.3 a couple weeks ago.

Regards,

The only other thing is if postgres isn’t running, or something wrong with gitlab.rb in terms of configuration causing it to fail - incorrect parameter, or something in the file that shouldn’t be. The error hints at problems connecting to postgres.

gitlab-ctl status

if you stopped gitlab before upgrading, better not to do this. Better to leave running and let gitlab start/stop during upgrade.

I’ve run sudo -E EXTERNAL_URL=“https://gitlab..com” apt-get install gitlab-ce on a clean ubuntu 18.04 server.

Same problem.

This is a fresh install, not an upgrade.

I’ll check gitlab.rb in case there is something wrong with it.

Gitlab-ctl status:

sudo gitlab-ctl status
run: gitaly: (pid 13114) 543s; run: log: (pid 12949) 602s
down: postgresql: 1s, normally up, want up; run: log: (pid 12964) 597s
run: redis: (pid 12769) 611s; run: log: (pid 12792) 608s

Regards,

Olivier

See if you can start postgres:

gitlab-ctl start postgresql

if fails, check logs: /var/log/gitlab/postgresql/current

sudo cat /etc/gitlab/gitlab.rb

## Latest options listed at [https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template)

external_url "[http://gitlab.xxxxx.com](http://gitlab.xxxxx.com)"

gitlab_rails["time_zone"] = "Hong Kong"

gitlab_rails["smtp_enable"] = true
gitlab_rails["smtp_address"] = "[email-smtp.eu-west-1.amazonaws.com](http://email-smtp.eu-west-1.amazonaws.com)"
gitlab_rails["smtp_port"] = "465"
gitlab_rails["smtp_user_name"] = “xxxx"
gitlab_rails["smtp_password"] = “xxxxx"
gitlab_rails["smtp_domain"] = “[xxxxx.com](http://xxxxx.com)"
gitlab_rails["smtp_authentication"] = "plain"
gitlab_rails["smtp_enable_starttls_auto"] = true
gitlab_rails["smtp_tls"] = true
gitlab_rails["smtp_openssl_verify_mode"] = "none"

gitlab_rails["gitlab_email_enabled"] = true
gitlab_rails["gitlab_email_from"] = “[gitlab@xxxxx.com](mailto:gitlab@xxxxx.com)"
gitlab_rails["gitlab_email_display_name"] = “xxxxx Gitlab Server"
gitlab_rails["gitlab_email_reply_to"] = “[gitlab@xxxxx.com](mailto:gitlab@xxxxx.com)"

gitlab_rails["gitlab_default_theme"] = 2

## Default project feature settings
gitlab_rails["gitlab_default_projects_features_issues"] = false
gitlab_rails["gitlab_default_projects_features_merge_requests"] = true
gitlab_rails["gitlab_default_projects_features_wiki"] = false
gitlab_rails["gitlab_default_projects_features_snippets"] = false
gitlab_rails["gitlab_default_projects_features_builds"] = true
gitlab_rails["gitlab_default_projects_features_container_registry"] = false

gitlab_rails["incoming_email_enabled"] = false

## Build Artifacts
gitlab_rails["artifacts_enabled"] = true
gitlab_rails["artifacts_path"] = "/mnt/gitlab/artifacts"
gitlab_rails["artifacts_object_store_enabled"] = false
gitlab_rails["artifacts_object_store_direct_upload"] = true
gitlab_rails["artifacts_object_store_background_upload"] = true
gitlab_rails["artifacts_object_store_proxy_download"] = false
gitlab_rails["artifacts_object_store_remote_directory"] = "artifacts"
gitlab_rails["artifacts_object_store_connection"] = {
"aws_access_key_id" => “XXXXXXX",
"aws_secret_access_key" => “xxxxxxxxxxxxxx",
"endpoint" => "[https://sgp1.digitaloceanspaces.com](https://sgp1.digitaloceanspaces.com)",
"provider" => "AWS",
"region" => "sgp1"
}

## Git LFS
gitlab_rails["lfs_enabled"] = true
gitlab_rails["lfs_storage_path"] = "/mnt/gitlab/lfs"
gitlab_rails["lfs_object_store_enabled"] = true
gitlab_rails["lfs_object_store_remote_directory"] = "lfs"
gitlab_rails["lfs_object_store_connection"] = {
"aws_access_key_id" => “XXXXXXX",
"aws_secret_access_key" => “xxxxxxxxxxxxxx",
"endpoint" => "[https://sgp1.digitaloceanspaces.com](https://sgp1.digitaloceanspaces.com)",
"provider" => "AWS",
"region" => "sgp1"
}

gitlab_rails["manage_backup_path"] = true
gitlab_rails["backup_path"] = "/mnt/gitlab/backups"
gitlab_rails["backup_upload_connection"] = {
"aws_access_key_id" => “XXXXXXX",
"aws_secret_access_key" => “xxxxxxxxxxxxxx",
"endpoint" => "[https://sgp1.digitaloceanspaces.com](https://sgp1.digitaloceanspaces.com)",
"provider" => "AWS",
"region" => "sgp1"
}
gitlab_rails["backup_upload_remote_directory"] = 'backups'
gitlab_rails["backup_multipart_chunk_size"] = 104857600

letsencrypt["enable"] = true

gitlab_rails["registry_enabled"] = false
registry["enable"] = false

nginx["enable"] = true
# nginx["client_max_body_size"] = '250m'
nginx["redirect_http_to_https"] = true
nginx["redirect_http_to_https_port"] = 80

Also tried first deleting /etc/gitlab/gitlab.rb. Same error.

sudo gitlab-ctl start postgresql
ok: run: postgresql: (pid 32638) 0s

OK, now if you repeat gitlab-ctl status and postgres is running, try running the gitlab-ctl reconfigure command and see if it will work now, as previously was problems because postgres wasn’t running.

Thanks Ian,

The problem was with the gitlab-secrets.json file.

Best regards,