Search code examples
amazon-ec2gitlabgitlab-ci-runner

GitLab Executor Error "You lack permissions to write to system configuration."


I have an AWS EC2 with Linux. I have installed GitLab runner on it, I've followed the https://docs.gitlab.com/runner/install/linux-repository.html for For RHEL/CentOS/Fedora. It is a Shell executor. I have registered it. And then installed Docker on EC2.

When I start pipeline though, I get this error:

Initialized empty Git repository in /home/gitlab-runner/builds/xxxx/0/xxxx/xxxx/.git/
Created fresh repository.
Checking out b25b6b1a as develop...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ amazon-linux-extras install docker
You lack permissions to write to system configuration.  /etc/yum.repos.d/amzn2-extras.repo

Any hint?


Solution

  • Since you're using the "shell" executor, commands that you run within your pipeline are essentially acting like you've SSH'd into the box with the gitlab-runner user (assuming you didn't change the user that the runners uses by default). That user is not going to have the privileges to install packages by default, which is the error you're seeing here.

    You'll want to add your gitlab-runner user to the sudoers file, then use sudo to run your command.

    All that having been said, is there a compelling reason for you to not use the docker executor? The isolation between jobs is much more clean. If you had multiple jobs running on a shell executor at the same time and they both install packages, for example, one of the two jobs will fail due to not being able to get a package lock. You can work around this with a resource_group, but docker is much more elegant of a solution.