Note that this playbook only tested in openSUSE Leap 15.1 and Ubuntu 18.04
You should prepare the VM/Server yourself. You could use the clone.sh
script if you already has VM named leap15.1
in your KVM Virtualization server.
If you just install minimal version of openSUSE Leap 15.1, you should install python
and python-xml
first. Thus package is needed by the zypper ansible module.
ansible all -i hosts -m raw -a "zypper install -y python python-xml" -u your-leap-user-name --become --become-user root --ask-become-pass
Clone the repository to local machine/ansible controller:
git clone URL
cd directory-name
Copy the required file:
cp hosts.example hosts
cp groups_vars/all.yml.example groups_vars/all.yml
Example of hosts file :
[runner]
runner01 ansible_host=10.1.1.220
runner02 ansible_host=10.1.1.221
runner03 ansible_host=10.1.1.222
Example of ansible variable file all.yml
runner_user: gitlab-runner
runner_timezone: Asia/Jakarta
runner_host_user: samsul
runner_registration_token: XXXEy5nG9jHQXXXXXXXX
runner_concurrent: 1
runner_coordinator_url: https://gitlab.com/
runner_description: The runner with the name
runner_executor: docker
runner_docker_image: alpine
runner_tags:
- dot
- docker
runner_path: /usr/local/bin/gitlab-runner
additional:
node_exporter:
deploy: yes
version: 0.18.0
arch: amd64
docker_exporter:
deploy: yes
port: 9323
ctop:
deploy: yes
version: 0.7.2
arch: amd64
Run the playbook
ansible-playbook -i hosts main.yml --ask-sudo-pass
type the sudo password and press Enter. You can omit the --ask-sudo-pass
if you already set the sudo without password.
If anything goes perfectly as expected, now is the time to register our runner. Go to your gitlab instance, either is gitlab.com or your own gitlab instance :
- in your project/group, go to Settings > CI/CD > Expand the Runner section,
- copy your runner registration token,
- back to your playbook, and open the
groups_vars/all.yml
file, - paste the token next to
runner_registration_token
, - change
runner_coordinator_url
value to your gitlab instance URL if needed, save the file, - go back to your terminal, then run:
ansible-playbook -i hosts register-runner.yml --ask-sudo-pass
- after the registration is finish, your runner should be available in your gitlab instance.
This work is licensed under Creative Commons Attribution 4.0
Created with ❤️ by Samsul Ma'arif for you, yes, you are.