GitLab Runner Executor Test Matrix
Categories:
This project provides a comprehensive test suite for validating GitLab Runner configurations across different executor types. It is part of the PHX (Phoenix) Ansible Reference Implementation and serves as a validation framework for testing GitLab Runner functionality in various deployment scenarios.
Refer to Manage GitLab Runners | C2 Platform for more information about GitLab Runner configuration in the PHX environment.
Purpose
This test project validates GitLab Runner operations across four different runner/executor combinations:
- Docker-in-Docker (DinD) operations - Testing containerized builds within containerized runners
- Shell executor functionality - Validating direct shell command execution
- Cross-executor compatibility - Ensuring pipelines work across different infrastructure types
- Runner infrastructure validation - Confirming proper configuration of PHX GitLab Runners
Runner Test Matrix
The project tests four distinct runner configurations. These configurations are defined in the PHX Ansible inventory at group_vars/gitlab_runner/runners.yml .
| Runner Tags | Description | Executor Type | Use Case |
|---|---|---|---|
vm-runner, docker-exe | GitLab Runner installed on VM with Docker executor | Docker | Container builds on VM |
vm-runner, shell-exe | GitLab Runner installed on VM with shell executor | Shell | Direct commands on VM |
container-runner, docker-exe | GitLab Runner installed in Container with Docker executor | Docker | Docker-in-Docker (DinD) |
container-runner, shell-exe | GitLab Runner installed in Container with shell executor | Shell | Shell commands in container |
Runner Configuration Details
1. VM Runner + Docker Executor (vm-runner, docker-exe)
- Infrastructure: GitLab Runner binary installed directly on a VM
- Executor: Docker - jobs run in Docker containers
- Docker Access: Uses host Docker daemon
- Best For: Standard containerized builds with full Docker access
- Configuration: See
inventory_hostname-dockerin PHX ansible config
2. VM Runner + Shell Executor (vm-runner, shell-exe)
- Infrastructure: GitLab Runner binary installed directly on a VM
- Executor: Shell - jobs run directly on the host shell
- Docker Access: May or may not have Docker depending on host setup
- Best For: Native builds, system-level operations, non-containerized workflows
- Configuration: See
inventory_hostname-shellin PHX ansible config
3. Container Runner + Docker Executor (container-runner, docker-exe)
- Infrastructure: GitLab Runner running as a Docker container
- Executor: Docker - jobs run in nested Docker containers (DinD)
- Docker Access: Requires Docker-in-Docker (DinD) service
- Special Requirements:
- Docker-in-Docker service (
docker:dind) - TLS certificates configuration
DOCKER_HOST=tcp://docker:2376- Privileged mode may be needed
- Docker-in-Docker service (
- Best For: Fully containerized CI/CD environments
- Configuration: See
inventory_hostname-dindin PHX ansible config - Custom Image: Uses
gitlab/c2-gitlab-runner:latestwith C2 certificates
4. Container Runner + Shell Executor (container-runner, shell-exe)
- Infrastructure: GitLab Runner running as a Docker container
- Executor: Shell - jobs run in the runner container’s shell
- Docker Access: Typically no Docker access (running inside container)
- Best For: Lightweight jobs in containerized runner environments
- Configuration: See
inventory_hostname-sind(Shell-in-Docker) in PHX ansible config - Custom Image: Uses
gitlab/c2-gitlab-runner:latestwith C2 certificates
Pipeline Structure
The GitLab CI/CD pipeline (.gitlab-ci.yml) is organized into three stages:
Stage 1: Build
Job: build:test-image
- Builds a test Docker image on Docker-capable executors
- Uses matrix execution to test both VM and Container runners with Docker executor
- Tests Docker build operations and validates the built image
- Runs on:
vm-runner,docker-execontainer-runner,docker-exe
Stage 2: Test
Job: test:docker-operations
- Executes comprehensive Docker functionality tests
- Validates Docker commands:
ps,images,build,run - Tests Docker-in-Docker capability
- Generates detailed test result artifacts
- Runs on:
vm-runner,docker-execontainer-runner,docker-exe
Job: test:shell-operations
- Tests basic shell executor functionality
- Validates file system operations
- Checks environment variable access
- Tests Docker availability (if present)
- Runs on:
vm-runner,shell-execontainer-runner,shell-exe
Stage 3: Validate
Job: validate:matrix-complete
- Confirms all four runner types were successfully tested
- Provides summary of validation results
- Single job that runs after all tests complete
Job: diagnostics:inspect-runner (Manual)
- Detailed runner inspection across all four configurations
- System information gathering
- Tool availability checks
- Docker configuration details (if applicable)
- Triggered manually for troubleshooting
Files in This Project
Core Files
Dockerfile: Test container image definition- Based on Alpine Linux
- Includes Docker CLI, bash, curl, git
- Used for testing containerized operations
entrypoint.sh: Container entrypoint script- Displays environment information
- Checks Docker availability
- Runs validation tests
test-docker.sh: Docker functionality test script- Tests Docker installation and daemon access
- Validates Docker commands (ps, images, build, run)
- Detects Docker-in-Docker configuration
- Generates detailed test reports
.gitlab-ci.yml: GitLab CI/CD pipeline configuration- Matrix execution for 4 runner types
- Docker-in-Docker configuration
- Comprehensive test coverage
Usage
Running the Full Test Suite
Push changes to trigger the pipeline automatically:
git push origin masterOr trigger manually from GitLab UI:
- Navigate to CI/CD → Pipelines
- Click “Run Pipeline”
Understanding Test Results
Successful Pipeline
A successful pipeline indicates:
- ✅ All four runner types are properly configured
- ✅ Docker operations work on Docker executors
- ✅ Shell operations work on all executors
- ✅ Docker-in-Docker is properly configured for container runners
Artifacts
Each test job generates artifacts:
- Docker tests:
docker-test-results.txt- Detailed Docker operation results - Shell tests:
test-shell.txt- Shell execution validation - Diagnostics: Complete system information for each runner type
Artifacts are available for download from the pipeline page and expire after 30 days.
Manual Diagnostics
For detailed runner inspection:
- Navigate to CI/CD → Pipelines → Select a pipeline
- Find the
diagnostics:inspect-runnerjobs in the validate stage - Click the play button (▶️) on the specific runner type you want to inspect
- Review the job output for detailed system information
Docker-in-Docker (DinD) Configuration
The most complex scenario tested is Container Runner + Docker Executor, which requires Docker-in-Docker:
Key Configuration Elements
services:
- docker:24-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
DOCKER_TLS_CERTDIR: "/certs"
How DinD Works
- GitLab Runner container starts
- Job container is created inside runner
- Docker-in-Docker (DinD) service container starts
- DinD service generates TLS certificates
- Job container connects to DinD daemon via TCP
- Docker commands in job execute on DinD daemon
Common DinD Issues
- Certificate errors: Ensure
DOCKER_TLS_CERTDIRis properly configured - Connection refused: Check
DOCKER_HOSTpoints totcp://docker:2376 - Permission denied: May require privileged mode in runner configuration
PHX Infrastructure Requirements
This test project requires the PHX environment to have:
- At least one VM runner with both Docker and Shell executors configured
- At least one Container runner with both Docker and Shell executors configured
- Proper runner tags matching the matrix configuration
- Docker daemon accessible on VM runners
- Docker-in-Docker capability for container runners
- C2 Platform certificates trusted in container runners
Verifying Runner Registration
Check that runners are registered with correct tags:
# On the GitLab instance
sudo gitlab-runner list
Expected tags for each runner:
- VM Docker runner:
vm-runner,docker-exe, plus host-specific tags - VM Shell runner:
vm-runner,shell-exe, plus host-specific tags - Container Docker runner:
container-runner,docker-exe, plus host-specific tags - Container Shell runner:
container-runner,shell-exe, plus host-specific tags
Troubleshooting
Pipeline Fails on Specific Runner Type
- Check runner is registered and active in GitLab (Settings → CI/CD → Runners)
- Verify runner tags match the expected tags
- Run manual diagnostics job for that specific runner type
- Check runner logs on the host system
Docker-in-Docker Fails
Verify Docker-in-Docker service is starting:
services: - docker:24-dindCheck TLS certificate generation in job logs
Ensure
DOCKER_HOSTis set totcp://docker:2376Verify runner has Docker privileged mode enabled (if required)
Shell Executor Can’t Find Commands
- Check if required tools are installed on the host
- Verify PATH is properly set for the gitlab-runner user
- For container shell executors, check if tools are in the runner image
No Runners Available
- Ensure runners are registered with the project or group
- Check runner tags match job requirements
- Verify runners are not paused
- Check runner token is valid
Integration with PHX Ansible
This project validates the GitLab Runner configuration managed by PHX Ansible:
- Runner Configuration:
group_vars/gitlab_runner/runners.yml - Custom Image:
group_vars/gitlab_runner/image.yml - Runner Role:
roles/gitlab_runner/
Changes to runner configuration in PHX Ansible should be validated by running this test pipeline.
Expected Outcomes
All Tests Pass
- GitLab Runners are properly configured
- Both VM and container-based runners are operational
- Docker executors can build and run containers
- Shell executors can execute commands
- Docker-in-Docker is working for containerized runners
Specific Test Fails
- Check the specific runner configuration
- Review job logs for detailed error messages
- Run manual diagnostics for the failing runner type
- Verify PHX Ansible runner configuration
Contributing
When modifying this project:
- Test changes on all four runner types
- Update documentation for any new test scenarios
- Ensure backward compatibility with existing runners
- Add new test cases as separate jobs when possible
Related Documentation
- PHX GitLab Runner Documentation
- GitLab Runner Executors
- Docker-in-Docker with GitLab CI
- PHX Ansible Repository
License
This project is part of the C2 Platform PHX Reference Implementation.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.