Merge branch 'gitlab-runner' into 'master'

Gitlab runner

See merge request mg/ansible!30
This commit is contained in:
Michael Grote 2021-01-17 19:34:17 +01:00
commit 69d9951815
13 changed files with 102 additions and 17 deletions

1
.gitmodules vendored
View file

@ -40,3 +40,4 @@
[submodule "roles/geerlingguy.gitlab"]
path = roles/geerlingguy.gitlab
url = https://github.com/geerlingguy/ansible-role-gitlab

View file

@ -1,5 +1,26 @@
# ansible_heimserver
## collections als Dependency
- in meta
```
collections:
- community.general
```
## defaults in Dictionary
```bash
- name: "register_runner"
community.general.gitlab_runner:
description: "{{ description|default('GitLab-Runner') }}"
```
```
description: <-- Original-Variable
"{{ item.description| <-- Original-Inhalt
default('GitLab-Runner') }}" <-- wenn Inhalt leer, dann default...
```
## playbook-grapher
`ansible-playbook-grapher --include-role-tasks tests/fixtures/with_roles.yml`

View file

@ -47,18 +47,18 @@
ufw_default_outgoing_policy: allow
### ryandaniels.create_users
users:
- username: mg
password: "{{ lookup('keepass', 'linux_mg_user_password_hash', 'password') }}"
update_password: on_create
ssh_key: "{{ lookup('keepass', 'ssh_pubkey_mg', 'password') }}"
use_sudo: yes
use_sudo_nopass: yes
user_state: present
groups: ssh, sudo
servers:
- production
- staging
- test
- username: mg
password: "{{ lookup('keepass', 'linux_mg_user_password_hash', 'password') }}"
update_password: on_create
ssh_key: "{{ lookup('keepass', 'ssh_pubkey_mg', 'password') }}"
use_sudo: yes
use_sudo_nopass: yes
user_state: present
groups: ssh, sudo
servers:
- production
- staging
- test
### geerlingguy.dotfiles
dotfiles_repo: "https://git.mgrote.net/mg/dotfiles"
dotfiles_repo_local_destination: "/home/mg/dotfiles-repo"

View file

@ -28,9 +28,6 @@
- production
- staging
- test
- virt
- cephq
- k8s
### mgrote.restic
restic_folders_to_backup: /usr/local /etc /root /home /var/lib/docker
restic_cron_hours: "*"

View file

@ -0,0 +1,17 @@
---
### geerlingguy.docker
docker_users:
- mg
- root
- ansible-user
### geerlingguy.pip
pip_package: python3-pip
pip_install_packages:
- name: python-gitlab
### mgrote.gitlab-runner
gitlab_runner:
- api_url: https://git.mgrote.net
registration_token: "{{ lookup('keepass', 'gitlab_runner_registration_token', 'password') }}"
api_token: "{{ lookup('keepass', 'gitlab_runner_api_token', 'password') }}" #Token: ansible-gitlab-runner
api_username: root
description: "{{ ansible_hostname }}"

View file

@ -54,12 +54,16 @@ all:
gitea-staging.grote.lan:
gitea-test.grote.lan:
gitea.grote.lan:
gitlab: # immer auch unten in den 2 Gruppen eintragen, sonst schlägt in Bootstrap das verteilen der ssh-keys fehl
gitlab:
hosts:
gitlab-staging.grote.lan:
gitlab-test.grote.lan:
gitlab.grote.lan:
gitlabrunner: # immer auch unten in den 2 Gruppen eintragen, sonst schlägt in Bootstrap das verteilen der ssh-keys fehl
hosts:
gitlab-runner-staging.grote.lan:
gitlab-runner-test.grote.lan:
gitlab-runner.grote.lan:
# wsl:
# hosts:
# irantu.grote.lan:
@ -85,6 +89,7 @@ all:
jenkins.grote.lan:
gitea.grote.lan:
gitlab.grote.lan:
gitlab-runner.grote.lan:
staging:
hosts:
wireguard-staging.grote.lan:
@ -98,6 +103,7 @@ all:
jenkins-staging.grote.lan:
gitea-staging.grote.lan:
gitlab-staging.grote.lan:
gitlab-runner-staging.grote.lan:
test:
hosts:
wireguard-test.grote.lan:
@ -113,3 +119,4 @@ all:
jenkins-test.grote.lan:
gitea-test.grote.lan:
gitlab-test.grote.lan:
gitlab-runner-test.grote.lan:

Binary file not shown.

View file

@ -0,0 +1,7 @@
---
- hosts: gitlabrunner
roles:
- { role: geerlingguy.pip, tags: "pip", become: true }
- { role: geerlingguy.docker, tags: "docker", become: true }
- { role: gantsign.ctop, tags: "ctop", become: true }
- { role: mgrote.gitlab-runner, tags: "gitlab-runner", become: true }

View file

@ -0,0 +1,10 @@
## mgrote.gitlab_runner
### Beschreibung
Installiert einen Gitlab-Runner.
### Funktioniert auf
- [X] Ubuntu (>=18.04)
### Variablen + Defaults
see [defaults](./defaults/main.yml)

View file

@ -0,0 +1,3 @@
---
gitlab_runner_arch: amd64 #https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.html
gitlab_runner_dl_link: "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_{{ gitlab_runner_arch }}.deb"

View file

@ -0,0 +1,13 @@
---
- name: "register_runner"
community.general.gitlab_runner:
api_url: "{{ item.api_url }}"
registration_token: "{{ item.registration_token }}"
api_token: "{{ item.api_token }}"
description: "{{ item.description|default('GitLab-Runner') }}"
state: "{{ item.state|default('present') }}"
active: "{{ item.active|default('True') }}"
run_untagged: True
locked: "{{ item.locked|default('False') }}"
loop: "{{ gitlab_runner }}"
no_log: true

View file

@ -0,0 +1,3 @@
---
collections: # Damit wird die Collection, wenn nicht vorhanden, als Abhängigkeit heruntergeladen.
- community.general

View file

@ -0,0 +1,6 @@
---
- name: Install deb package
apt:
deb: "{{ gitlab_runner_dl_link }}"
state: present
notify: register_runner