Initial commit
This commit is contained in:
commit
70c8393f0b
13 changed files with 185 additions and 0 deletions
5
.ansible-lint
Normal file
5
.ansible-lint
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
parseable: true
|
||||||
|
quiet: true
|
||||||
|
skip_list:
|
||||||
|
- '501'
|
||||||
|
use_default_rules: true
|
||||||
41
.gitlab-ci.yml
Normal file
41
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
- test
|
||||||
|
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- .cache/pip
|
||||||
|
- node_modules/
|
||||||
|
|
||||||
|
lint:
|
||||||
|
stage: lint
|
||||||
|
image: python:3.7
|
||||||
|
before_script:
|
||||||
|
- pip install ansible ansible-lint --quiet
|
||||||
|
script:
|
||||||
|
- ansible-lint playbook.yml
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- development
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
|
pretty-lint:
|
||||||
|
stage: lint
|
||||||
|
image: node:12
|
||||||
|
before_script:
|
||||||
|
- npm install
|
||||||
|
script:
|
||||||
|
- npx prettier "roles/**/*.yml" --check
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- development
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
|
syntax-test:
|
||||||
|
stage: test
|
||||||
|
image: python:3.7
|
||||||
|
before_script:
|
||||||
|
- pip install ansible ansible-lint --quiet
|
||||||
|
script:
|
||||||
|
- ansible-playbook playbook.yml --syntax-check
|
||||||
9
.prettier.json
Normal file
9
.prettier.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 90,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"parser": "yaml"
|
||||||
|
}
|
||||||
|
|
||||||
2
ansible.cfg
Normal file
2
ansible.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[defaults]
|
||||||
|
roles_path = ./roles
|
||||||
16
inventory.yml
Normal file
16
inventory.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
gitlab-runner:
|
||||||
|
hosts:
|
||||||
|
192.168.178.87:
|
||||||
|
host_interface : "en*"
|
||||||
|
host_ip : "192.168.178.87"
|
||||||
|
host_subnet : "24"
|
||||||
|
host_gateway : "192.168.178.1"
|
||||||
|
host_dns : "192.168.178.1"
|
||||||
|
hostname: "gitlab-runner-2"
|
||||||
|
192.168.178.192:
|
||||||
|
host_interface : "en*"
|
||||||
|
host_ip : "192.168.178.192"
|
||||||
|
host_subnet : "24"
|
||||||
|
host_gateway : "192.168.178.1"
|
||||||
|
host_dns : "192.168.178.1"
|
||||||
|
hostname: "gitlab-runner-1"
|
||||||
5
playbook.yml
Normal file
5
playbook.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- hosts: gitlab-runner
|
||||||
|
become: yes
|
||||||
|
become_method: sudo
|
||||||
|
roles:
|
||||||
|
- gitlab_runner
|
||||||
6
roles/.gitignore
vendored
Normal file
6
roles/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# ignore all external roles and files in the roles dir
|
||||||
|
/*
|
||||||
|
|
||||||
|
!.gitignore
|
||||||
|
!requirements.yml
|
||||||
|
!gitlab_runner*/
|
||||||
8
roles/gitlab_runner/defaults/main.yml
Normal file
8
roles/gitlab_runner/defaults/main.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
default_user: "sonny"
|
||||||
|
|
||||||
|
gitlab_repo: "deb https://packages.gitlab.com/runner/gitlab-runner/debian/ buster main"
|
||||||
|
gitlab_runner_gpg: "https://packages.gitlab.com/runner/gitlab-runner/gpgkey"
|
||||||
|
|
||||||
|
docker_repo: "deb https://download.docker.com/linux/debian buster stable"
|
||||||
|
docker_gpg: "https://download.docker.com/linux/debian/gpg"
|
||||||
|
docker_gpg_id: "0EBFCD88"
|
||||||
5
roles/gitlab_runner/handlers/main.yml
Normal file
5
roles/gitlab_runner/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: restart gitlab-runner
|
||||||
|
systemd:
|
||||||
|
name: gitlab-runner
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
16
roles/gitlab_runner/meta/main.yml
Normal file
16
roles/gitlab_runner/meta/main.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
dependencies:
|
||||||
|
- common
|
||||||
|
|
||||||
|
galaxy_info:
|
||||||
|
author: sonny
|
||||||
|
description: "Gitlab-runner installation"
|
||||||
|
license: "license GPLv3"
|
||||||
|
min_ansible_version: 2.7
|
||||||
|
issue_tracker_url: "https://git.fudiggity.nl/ansible/gitlab-runner/-/issues"
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- buster
|
||||||
|
galaxy_tags:
|
||||||
|
- development
|
||||||
|
- system
|
||||||
62
roles/gitlab_runner/tasks/main.yml
Normal file
62
roles/gitlab_runner/tasks/main.yml
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
- include_role:
|
||||||
|
name: common
|
||||||
|
tasks_from: "network.yml"
|
||||||
|
- include_role:
|
||||||
|
name: common
|
||||||
|
tasks_from: "host.yml"
|
||||||
|
|
||||||
|
- name: copy apt preference file
|
||||||
|
template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
loop:
|
||||||
|
- {
|
||||||
|
src: "apt-pin.j2",
|
||||||
|
dest: "/etc/apt/preferences.d/pin-gitlab-runner.pref",
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Add docker gpg key
|
||||||
|
apt_key:
|
||||||
|
id: "{{ docker_gpg_id }}"
|
||||||
|
url: "{{ docker_gpg }}"
|
||||||
|
validate_certs: yes
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add gitlab-runner gpg key
|
||||||
|
apt_key:
|
||||||
|
url: "{{ gitlab_runner_gpg }}"
|
||||||
|
validate_certs: yes
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add docker repo
|
||||||
|
apt_repository:
|
||||||
|
repo: "{{ docker_repo }}"
|
||||||
|
validate_certs: yes
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add gitlab-runner repo
|
||||||
|
apt_repository:
|
||||||
|
repo: "{{ gitlab_repo }}"
|
||||||
|
validate_certs: yes
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: install packages # noqa 403
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- gitlab-runner
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
update_cache: true
|
||||||
|
state: latest
|
||||||
|
notify:
|
||||||
|
- restart gitlab-runner
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
|
||||||
|
# see https://gitlab.com/gitlab-org/gitlab-runner/issues/305
|
||||||
|
- name: ensure docker is restarted
|
||||||
|
service: name=docker state=restarted enabled=yes
|
||||||
6
roles/gitlab_runner/templates/apt-pin.j2
Normal file
6
roles/gitlab_runner/templates/apt-pin.j2
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
|
||||||
|
Explanation: Prefer GitLab provided packages over the Debian native ones
|
||||||
|
Package: gitlab-runner
|
||||||
|
Pin: origin packages.gitlab.com
|
||||||
|
Pin-Priority: 1001
|
||||||
4
roles/requirements.yml
Normal file
4
roles/requirements.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
- src: git+https://git.fudiggity.nl/ansible/common.git
|
||||||
|
name: common
|
||||||
|
version: master
|
||||||
|
scm: git
|
||||||
Reference in a new issue