Initial commit

This commit is contained in:
Sonny Bakker 2020-11-07 21:26:04 +01:00
commit 70c8393f0b
13 changed files with 185 additions and 0 deletions

5
.ansible-lint Normal file
View file

@ -0,0 +1,5 @@
parseable: true
quiet: true
skip_list:
- '501'
use_default_rules: true

41
.gitlab-ci.yml Normal file
View 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
View file

@ -0,0 +1,9 @@
{
"singleQuote": true,
"printWidth": 90,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"parser": "yaml"
}

2
ansible.cfg Normal file
View file

@ -0,0 +1,2 @@
[defaults]
roles_path = ./roles

16
inventory.yml Normal file
View 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
View file

@ -0,0 +1,5 @@
- hosts: gitlab-runner
become: yes
become_method: sudo
roles:
- gitlab_runner

6
roles/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
# ignore all external roles and files in the roles dir
/*
!.gitignore
!requirements.yml
!gitlab_runner*/

View 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"

View file

@ -0,0 +1,5 @@
- name: restart gitlab-runner
systemd:
name: gitlab-runner
state: restarted
enabled: yes

View 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

View 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

View 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
View file

@ -0,0 +1,4 @@
- src: git+https://git.fudiggity.nl/ansible/common.git
name: common
version: master
scm: git