Disable shared runners.

This commit is contained in:
Robert de Bock 2022-11-01 10:42:33 +01:00
parent c67d681db8
commit 2a8178f843
4 changed files with 58 additions and 5 deletions

View File

@ -3,3 +3,16 @@
``` ```
./gitlab.yml --ask-vault-password -e role=ansible-role-xyz ./gitlab.yml --ask-vault-password -e role=ansible-role-xyz
``` ```
## Bulk
To update all roles:
```
echo "PASSWORD" > /tmp/bla.txt
ls -d ../ansible-role-* | cut -d/ -f2 | while read role ; do
echo "${role}"
./gitlab.yml --vault-password-file=/tmp/bla.txt -e role="${role}"
done
```

3
defaults/main.yml Normal file
View File

@ -0,0 +1,3 @@
---
gitlab_runner_id: 18209306

View File

@ -9,11 +9,12 @@
namespace: robertdebock namespace: robertdebock
vars_files: vars_files:
- defaults/main.yml
- vars/main.yml - vars/main.yml
- vars/vault.yml - vars/vault.yml
tasks: tasks:
- name: see if all veriables are set - name: see if all variables are set
assert: assert:
that: that:
- namespace is defined - namespace is defined
@ -55,7 +56,7 @@
protects: true protects: true
masked: true masked: true
- name: list pipelines - name: list pipeline schedules
uri: uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules" url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
method: GET method: GET
@ -63,7 +64,7 @@
PRIVATE-TOKEN: "{{ gitlab_private_token }}" PRIVATE-TOKEN: "{{ gitlab_private_token }}"
register: gitlab_schedules register: gitlab_schedules
- name: delete all pipelines - name: delete all pipeline schedules
uri: uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules/{{ item.id }}" url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules/{{ item.id }}"
method: DELETE method: DELETE
@ -89,3 +90,39 @@
ref: master ref: master
cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *" cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
cron_timezone: Amsterdam cron_timezone: Amsterdam
# - name: disable runnner
# uri:
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/runners/{{ gitlab_runner_id }}"
# method: DELETE
# body_format: json
# status_code:
# - 204
# - 404
# headers:
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
# body:
# runner_id: "{{ gitlab_runner_id }}"
- name: enable runnner
uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/runners"
method: POST
body_format: json
status_code:
- 201
- 400
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
body:
runner_id: "{{ gitlab_runner_id }}"
- name: disable shared runnners
uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}"
method: PUT
body_format: json
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
body:
shared_runners_enabled: false

View File

@ -1,8 +1,8 @@
--- ---
image: "robertdebock/github-action-molecule:4.0.8" image: "robertdebock/github-action-molecule:4.0.8"
services: # services:
- docker:dind # - docker:dind
variables: variables:
PY_COLORS: 1 PY_COLORS: 1