Run vagrant libvirt-kvm vms as envs for gitlab jobs.
Use https://docs.gitlab.com/runner/executors/custom.html for run libvirt kvm VMs use Vagrant as wrapper.
On runner host
- gitlab-runner register
and chose custom
- Edit section of creation runner in file /etc/gitlab-runner/config.toml
[[runners]]
name = "your-runner-name"
url = "https://gitlab.example.com"
token = "SUPERSECRETTOKEN"
executor = "custom"
output_limit = 16384 # optional
builds_dir = "/home/vagrant/builds"
cache_dir = "/home/vagrant/cache"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.custom]
prepare_exec = "/opt/vagrant-driver/prepare.sh"
run_exec = "/opt/vagrant-driver/run.sh"
cleanup_exec = "/opt/vagrant-driver/cleanup.sh"
-
Copy bash scripts and Vagrantfile in /opt/vagrant-driver
-
kill -SIGHUP $(pidof gitlab-runner) or restart runner process.
-
Install qemu, kvm, libvirt, Vagrant, etc...
-
vagrant plugin install vagrant-libvirt
Use this runner as usual
.gitlab-ci.yml
echo:
stage: test
script:
- echo test
tags:
- vagrant-executor
Or configure VMs (all vars bellow are default, you can change it)
echo:
stage: test
variables:
VAGRANT_VM_MEMORY: 2048
VAGRANT_VM_CPUS: 2
VAGRANT_BOX_NAME: andreineustroev/ubuntu-ci
VAGRANT_BOX_VERSION: 0.0.3
script:
- echo test
tags:
- vagrant-executor