How to Install and Configure GitLab Community Edition

img placeholder

GitLab Community Edition is a Open-source DecSecOps Platform

GitLab brings Automated tasks to improve the efficiency. Supports

  • Continuous Integration and Delivery
  • Workflows
  • Source Code Management
  • Automated Software delivery

Installation:

For this Guide, we will install GitLab community edition on Alma Linux

  1. Prepare Linux Machine

For Lab purpose i have created a VM with the following specs

GitLab VM
  • 8vCPU
  • 16GB RAM
  • 100GB free disk space
  • Alma Linux 9 with static IP

  1. Create the Virtual Machines manually or using Packer template and clone using Terraform/OpenTofu. I have used the OpenTofu code, which will create VM with the required configuration
    img placeholder
    Tofu/terrform code to create GitLab VM from template
  2. Login to GitLab VM and run the following commands.
1sudo systemctl disable --now firewalld

this stops the firewall service and disable it

img placeholder
4. install the prerequisites using the following command:

1sudo dnf install -y curl policycoreutils openssh-server perl

img placeholder
5. Add the GitLab package repository

1
2curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

img placeholder
6. Install the GitLab package using the following command

1sudo EXTERNAL_URL="http://repo.cloudbricks.local" dnf install -y gitlab

replace the EXTERNAL_URL with the one you need

img placeholder

Post complettion of installation, run the fowllowing command to check the status of gitlab.

1gitlab-ctl status

img placeholder
7. access the GitLab URL as mentioned in the previous steps. To get the initial root password run the follwing command

1cat /etc/gitlab/initial_root_password

img placeholder
In my case, i will be accessing using http://repo.cloudbricks.local with root as username and password from above command

  1. Change the root password immediately by going to root avatar > Edit profile > Password
    img placeholder
    img placeholder
    img placeholder

Confgure HTTPS:
  1. Login to GitLab VM and edit /etc/gitlab/gitlab.rb

    img placeholder

  2. uncomment the following

nginx['ssl_certificate'] = "/etc/gitlab/ssl/#{node['fqdn']}.crt""

nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqdn']}.key"

Uncomment and change this line from False to True nginx['redirect_http_to_https'] = true

nginx['ssl_client_certificate'] = "/etc/gitlab/ssl/ca.crt"

img placeholder

  1. create a directory called ssl under /etc/gitlab

    img placeholder

  2. Copy ADCS generated SSL certs to /etc/gitlab/ssl

    img placeholder

  3. change the external url from http to https - external_url 'https://repo.cloudbricks.local'

    img placeholder

  4. Once the SSL certificates are copied and gitlab.rb is edited properly, run the following command

1gitlab-ctl reconfigure
  1. Refresh the Gitlab URL/ open new tab and access the url
    img placeholder

Watch the video on How to install and configure GitLab community Edition