How to Setup a Local GitLab Source Code Management — Part II

Yann Mulonda
Dev Genius
Published in
5 min readDec 1, 2020

--

Intro to source code management With GitLab

Well now that we have our CentOS 8.2 template set up and ready. Let’s go ahead a create VM to host our GitLab source code management by cloning the template VM:

Things to double-check:

* Adapter 1 is set to NAT

* Adapter 2 is set to Host-only Adapter: vboxnet1

Network Configs

After powering on the Gitlab VM, we need to do all the network configuration for internet access and set the Static IP address on the second Adapter.

To do so, turn off both adapters on the VM and verify the IP address allocation:

$ ifconfig

The NAT adapter is enp0s3 and the Host-only adapter is enp0s8.

You’ll notice that the Host-only adapter is failing to connect and show the following error: “Activation of network connection failed” and enp0s8 doesn’t have an IP assigned to it. So let’s go ahead and fix that!

Setup Static IP Address for Host-only adapter: enp0s8

to set up a static IP address on a network interface in CentOS 7, there are several different ways to do it, varying depending on whether or not you want to use Network Manager for that.

Network Manager is a dynamic network control and configuration system that attempts to keep network devices and connections up and active when they are available). CentOS 8.2 comes with Network Manager service installed and enabled by default.

To verify the status of the Network Manager service:

$ systemctl status NetworkManager.service

To check which network interface is managed by Network Manager, run:

$ nmcli dev status
$ nmcli con show

If the output of nmcli shows connected for a particular interface (e.g., enp0s3 in this example), it means that the interface is managed by Network Manager. You can easily disable Network Manager for a particular interface so that you can configure it on your own for a static IP address.

Now, we can see that the Host-only:enp0s8 is failing under the name “Wire connection 1”.They are two different ways to assign a static IP address to a network interface on CentOS 8.2. We are going to Configure a Static IP Address without Network Manager.

Let’s go to the /etc/sysconfig/network-scripts directory, and locate the configuration file of the interface (ifcfg-enp0s3).

$ cd /etc/sysconfig/network-scripts
$ sudo nano ifcfg-enp0s3

Copy the following interface configuration and save your file under the name: ifcfg-enp0s8

This is my ifcfg-enp0s8 interface configuration

Next, restart the Network Manager service and check that the Host-only:enp0s8 has an assigned IP address and is now is managed by Network Manager:

$ systemctl restart NetworkManager.service
$ systemctl status NetworkManager.service
$ nmcli dev status
$ nmcli con show
$ ifconfig

We’ll set! 😃😉 — Now you can ssh into your VM from your mac and install a Gitlab instance that’ll run on the VM!

The password will be the same → osboxes.org

ssh root@192.168.56.155

Install GitLab Instance

So there is a couple of ways we can install Gitlab on CentOS 8.2. Please go here: https://about.gitlab.com/install/ to learn about those different options. Feel free to go with whichever option you feel comfortable with. So let’s start by installing docker in our VM.

Install Docker in CentOS 8.2

Instruction on how to install docker on CentOS can be found here. But first, we need to manually install the containerd.io package otherwise we’ll get an error of this package missing. We can find the most recent version here https://download.docker.com/linux/centos/8/x86_64/stable/Packages/:

$ sudo yum install --allowerasing -y https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.9-3.1.el8.x86_64.rpm

Next, we’ll use the script at get.docker.com to install the latest release of Docker Engine by running the following commands:

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ service docker start
Install docker on CentOS 8.2 — Screenshot

Install GitLab

We are going to use the GitLab Docker image to install GitLab in our VM. The GitLab Docker images are monolithic images of GitLab running all the necessary services in a single container.

Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside. Ensure that the directory exists and appropriate permission has been granted. Set the path to /srv/gitlab:

$ export GITLAB_HOME=/srv/gitlab

Once you’ve set up the GITLAB_HOME variable, you can run the image. The hostname will be the static IP address we set up on the Host-only:enp0s8:

sudo docker run --detach \
--hostname 192.168.56.155 \
--publish 443:443 --publish 80:80 --publish 9222:22 \
--name mygitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/mygitlab \
--volume $GITLAB_HOME/logs:/var/log/mygitlab \
--volume $GITLAB_HOME/data:/var/opt/mygitlab \
gitlab/gitlab-ee:latest

It’s very important that you make sure that the IP address used as the hostname doesn’t change.

Once deployed, wait for it to initialize. This might take a couple of minutes. You can monitor it using the docker log:docker log containerID -f command:

Now you go to your browser and navigate to your local Gitlad source code management instance http://192.168.56.155/

You’ll be asked to set a password and then use:

  • username → root
  • password → “the new password you setup”
http://192.168.56.155/ — Screenshot

Done! now you have your own Source code management that you can use private project hosted on-prem or whatever 🤷🏾‍♂️ 😉👌

If you enjoyed this story, you might also like “How to setup OpenShift Locally on Mac OS

Cheers!!!

--

--

Co-Founder & CIO @ITOT | DevOps | Senior Site Reliability Engineer @ICF󠁧󠁢󠁳󠁣󠁴 | "Learning is experience; everything else is just information!”