https://github.com/samsulmaarif/ansible-gitlab-runner
https://github.com/samsulmaarif/ansible-gitlab-runner
ansible automation gitlab-ci gitlab-runner
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/samsulmaarif/ansible-gitlab-runner
- Owner: samsulmaarif
- Created: 2019-07-05T07:11:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T03:26:38.000Z (about 6 years ago)
- Last Synced: 2025-10-10T07:03:10.594Z (8 months ago)
- Topics: ansible, automation, gitlab-ci, gitlab-runner
- Language: Shell
- Size: 17.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ansible Playbook to Deploy GitLab Runner
Note that this playbook only tested in openSUSE Leap 15.1 and Ubuntu 18.04
## Prepare the VM/Server
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
```
## How to use
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 :
1. in your project/group, go to **Settings** > **CI/CD** > Expand the **Runner** section,
2. copy your **runner registration token**,
3. back to your playbook, and open the `groups_vars/all.yml` file,
4. paste the token next to `runner_registration_token`,
5. change `runner_coordinator_url` value to your gitlab instance URL if needed, save the file,
6. go back to your terminal, then run:
```
ansible-playbook -i hosts register-runner.yml --ask-sudo-pass
```
7. after the registration is finish, your runner should be available in your gitlab instance.
## License

This work is licensed under [Creative Commons Attribution 4.0](http://creativecommons.org/licenses/by/4.0/)
## Author
Created with :heart: by [Samsul Ma'arif](https://github.com/samsulmaarif) for you, yes, you are.