Home:ALL Converter>GitLab CI/CD Pipeline - Run Linux commands interactively on GitLab Runner

GitLab CI/CD Pipeline - Run Linux commands interactively on GitLab Runner

Ask Time:2022-09-04T22:03:09         Author:hitman126

Json Formatter

I am trying to provision and configure some Azure infrastructure using terraform which will be orchestrated via a GitLab CI/CD pipeline running off a GitLab Runner hosted on an Azure Linux VM. The Azure Linux VM which has been manually provisioned, has a named Admin called azureuser.

I'd like to install and configure the GitLab Runner (including its dependencies) using a dedicated GitLab CI/CD pipeline and as a result, run all the required Linux commands interactively on the aforementioned Azure Linux VM. How can I achieve this?

I've been following the steps outlined in this GitLab documentation https://docs.gitlab.com/ee/ci/ssh_keys/ and as part of an initial dry-run, I manually installed the GitLab Runner on my Azure Linux VM using the Root account.

On the other hand, I did create the required Private and Public Keys in the home directory of the azureuser account as depicted in the screenshot below. I manually run all the checks to confirm that the GitLab Runner and Docker Executor were both up and running, as well as other dependencies.

enter image description here

Then from my .gitlab-ci.yml file, I tried to execute some very basic Linux commands - sudo yum -y update and sudo gitlab-runner status - but then received the following error message:

.gitlab-ci.yml interactive command

/bin/sh: eval: line 146: sudo: not found

sudo: not found error

  1. What could I be doing wrong when trying to run those commands interactively on my Azure Linux VM GitLab Runner?

  2. Was it okay for me to install the Runner and also generate the SSH keys with two different accounts as described above?

Author:hitman126,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73600028/gitlab-ci-cd-pipeline-run-linux-commands-interactively-on-gitlab-runner
yy