Skip to content

How to Install GitLab in a Disconnected Environment


GitLab is an open source DevOps platform with functionalities such as Git server, CI/CD, DevSecOps and many other features. You can use hosted service at gitlab.com or you can install GitLab on your server and use it. However, most of the people using GitLab as a Git server rather than the full DevOps platform. Anyway, if you need a fully functional Git server for your environment, one of the best options is GitLab and you can install it for free by using GitLab CE (Community Edition). If you need support, then check for GitLab EE (Enterprise Edition).

Installing GitLab is a simple job as you just need to install the dependancies and then GitLab package. But the process is bit different when you do not have internet on your server (restricted or disconnected environment) on which you want to install GitLab.

In this tutorial, you will learn how to install GitLab CE in a disconnected (no Internet) server.

Learn how to install git server using gogs

Prerequisites

  • Server to install GitLab CE – Check requirements for CPU, Memory, storage details.
  • GitLab CE package downloaded
  • Operating System repositories

Download GitLab Package

Since we cannot simple install GitLab using package managers (yum, dnf, apt), we need to download the the package manually (from a machine with internet access) and transfer to the server.Download the package from packages.gitlab.com and in my case I am installing GitLab Ce on a RHEL8 server (Red Hat Enterprise Linux).

Find the rpm link (or whichever package you are installing) and click on the link. In my case I am downloading gitlab-ce-14.5.2-ce.0.el8.x86_64.rpm (el8) for RHEL8.

In the next screen, you will see the link for downloading the rpm file (Upper right corner as shown below). Click on the download link.

Note: You can download the rpm file using curl from an internet connected machine as well.

$ wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/8/gitlab-ce-14.5.2-ce.0.el8.x86_64.rpm/download.rpm

Check OpenShift BootCamp to learn OpenShift from scratch.

Transfer Package to the Server

You can use any of the allowed methods (scp, winscp etc) to transfer the package (RPM) to the GitLab server.

Install and Enable Dependancies

Make sure you have access to the operating system repositories to install the dependancy packages. Eg: for RHEL8, make sure you have access to the Satellite server or local yum repositories enabled.

$ sudo dnf install -y \
    curl \
    policycoreutils \
    openssh-server \
    perl \
    postfix \
    openssl \
    tzdata \
    yum-utils

Make sure sshd is working (If you are already connected via ssh then this steps is already done. If you are using server remote console, then enable sshd)

# Enable OpenSSH server daemon if not enabled: 
sudo systemctl status sshd
sudo systemctl enable sshd 
sudo systemctl start sshd

Enable firewall ports for GitLab access.

sudo systemctl status firewalld
$ sudo firewall-cmd --permanent --add-service=http && \
    sudo firewall-cmd --permanent --add-service=https && \
    sudo systemctl reload firewalld

Enable Postfix for email.

$ sudo dnf install postfix && \
    sudo systemctl enable postfix && \
    sudo systemctl start postfix

Install GitLab Server Offline

Now you can install GitLab CE package using dnf localinstall (or use alternative command for your operating system). Remember to configure the environment variable for EXTERNAL_URL and GITLAB_ROOT_PASSWORD.

The EXTERNAL_URL you are using should a valid DNS or you need to add the entry in your /etc/hosts file on the client machine from where you are accessing the GitLab server.

$ sudo EXTERNAL_URL="http://gitlab.lab.local" \
    GITLAB_ROOT_PASSWORD="gitlabadmin" \
    dnf localinstall -y gitlab-ce-14.5.2-ce.0.el8.x86_64.rpm

Note: If any error with gpgcheck, then disable gpgcheck by adding --nogpgcheck at the end of dnf or yum command.

GitLab Initial root Password

If you missed to mention the root password while installing, then get the default random password generated by installer. (This password will be removed by gitlab-ctl reconfigure later.)

$ sudo cat /etc/gitlab/initial_root_password

Access the GitLab CE Server

Now you can access the GitLab CE server from a browser using the EXTERNAL_URL you have configured (eg: http://gitlab.lab.local).

Refer GitLab official documentation for further reading.

Disclaimer: The views expressed and the content shared are those of the author and do not reflect the views of the author’s employer or techbeatly platform.

Gineesh Madapparambath is the author of the book - 𝗔𝗻𝘀𝗶𝗯𝗹𝗲 𝗳𝗼𝗿 𝗥𝗲𝗮𝗹-𝗟𝗶𝗳𝗲 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan - iamgini.com)

Comments

2 Responses

  1. […] have explained How to Install GitLab in a Disconnected Environment in a past article. In this article you will learn how to use self-signed or custom SSL certificates […]

  2. […] have explained How to Install GitLab in a Disconnected Environment in a past article. In this article you will learn how to configure custom storage path for your […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: