gitlab-runner ERROR: Preparation failed: VBoxManageOutput error: VBoxManage: error: Could not find a registered machine named

Viewed 315

I want to use gitlab-runner virtualbox executor with just simple debian box so my vagrant file is

Vagrant.configure("2") do |config|
 config.vm.box = "debian/buster64"
end

First approach

  1. vagrant up
  2. change name: settings->general->name "my-vm"
  3. shut down vm
  4. sudo gitlab-runner register ...some manual commands...
  5. sudo gitlab-runner install --user $(whoami)
  6. sudo gitlab-runner start

I can see my runner in my Gitlab Settings CI. It's green. Then I run my job and I get the following problem: ERROR: Preparation failed: VBoxManageOutput error: VBoxManage: error: Could not find a registered machine named my-vm but in my console

VBoxManage list vms
"my-vm" {aaf0b3ff-3c5b-4324-9b2f-034d26036278}

Second approach (from scratch)

  1. vagrant up
  2. change name: settings->general->name "my-vm"
  3. shut down vm
  4. gitlab-runner register ...some manual commands...
    WARNING: Running in user-mode.                     
    WARNING: The user-mode requires you to manually start builds processing: 
    WARNING: $ gitlab-runner run                       
    WARNING: Use sudo for system-mode:                 
    WARNING: $ sudo gitlab-runner... 
    
  5. sudo gitlab-runner install --user $(whoami)
  6. sudo gitlab-runner start
  7. gitlab-runner run

The Second approach fixed the problem: my runner can see the box and everything works as expected but new one appear:

I don't want to execute gitlab-runner run every time when I want to run jobs. I prefer the first approach but I get the problem when my runner cant find box.

I can use sudo vagrant up and then change name via sudo VBoxManage way and it will work but it looks like more as a workaround.

I can't find any example or explanation how I can solve my issue. How people do this in a area of good practices?

0 Answers
Related