Part 2 CI: Setting up Gitlab Runner
In this article, I am going to set up Gitlab runner on premise through shell. Let's get started
First please go to terminal and perform sudo nano /etc/hosts, add the below and save
192.168.1.110 gitlab.testlabs.local
next in the terminal, download and install the gitlab-runner
curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
sudo dpkg -i gitlab-runner_amd64.deb
next we are going to edit the visudo
sudo visudo
In the file you would want the part below to look something like this
# User privilege specification
root ALL=(ALL:ALL) ALL
gitlab-runner ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "@include" directives:
@includedir /etc/sudoers.d
gitlab-runner ALL=(ALL) NOPASSWD: ALL
Next perform are gitlab-runner restart
sudo gitlab-runner restart
From here on, this is one of the most crucial step. If you had went straight to the gitlab page and create runner and to register the gitlab-runner, you will be in for a big mess. Here is something which I have spent few days to finally address.
Launch your Firefox or any browser. Open the gitlab.testlabs.local
Click on the cert icon and click on more information
Click on the security tab, click on the View Certificate. There will be a popup on the certificate. Scroll until you see the Download. Click to download the PEM(cert)
Next copy the file to the certificate folder
sudo cp localhost.pem /usr/share/ca-certificates/localhost.pem
sudo nano /etc/ca-certificates.conf
Scroll to the bottom and add the localhost.pem
Once you complete save and in the terminal, type
sudo update-ca-certificates
Now you are ready to start install gitlab runner
Go to your browser and open up the url gitlab.testlabs.local, login and go to Group. Click on Build. Create a new runner group
Click on Linux and
Now it has provided with a reference like this, go ahead and put that in the terminal.
gitlab-runner register --url https://gitlab.testlabs.local
--token glrt-29NkSeHBnKSCEWymaABC
You will be asked to input the url again, just put gitlab.testlabs.local
Next put in the executor as 'shell'
You can see the result in by doing this
sudo -i
cd /etc/gitlab-runner
nano config.toml
[[runners]]
name = "build01"
url = "https://gitlab.testlabs.local"
id = 1
token = "glrt-29NkSeHBnKSCEWymaABC"
token_obtained_at = 2023-06-22T16:05:42Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
Once you are done checking the config.toml, exit and go to your gitlab, check the runner and you will see it as online