diff --git a/README-gitlab.md b/README-gitlab.md index 45fc9c0..7e7ed63 100644 --- a/README-gitlab.md +++ b/README-gitlab.md @@ -3,3 +3,16 @@ ``` ./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 +``` diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..4cc766a --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +gitlab_runner_id: 18209306 diff --git a/gitlab.yml b/gitlab.yml index 4f75735..430e5de 100755 --- a/gitlab.yml +++ b/gitlab.yml @@ -9,11 +9,12 @@ namespace: robertdebock vars_files: + - defaults/main.yml - vars/main.yml - vars/vault.yml tasks: - - name: see if all veriables are set + - name: see if all variables are set assert: that: - namespace is defined @@ -55,7 +56,7 @@ protects: true masked: true - - name: list pipelines + - name: list pipeline schedules uri: url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules" method: GET @@ -63,7 +64,7 @@ PRIVATE-TOKEN: "{{ gitlab_private_token }}" register: gitlab_schedules - - name: delete all pipelines + - name: delete all pipeline schedules uri: url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules/{{ item.id }}" method: DELETE @@ -89,3 +90,39 @@ ref: master cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *" 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 diff --git a/templates/gitlab-ci.yml.j2 b/templates/gitlab-ci.yml.j2 index 1870566..dda4714 100644 --- a/templates/gitlab-ci.yml.j2 +++ b/templates/gitlab-ci.yml.j2 @@ -1,8 +1,8 @@ --- image: "robertdebock/github-action-molecule:4.0.8" -services: - - docker:dind +# services: +# - docker:dind variables: PY_COLORS: 1