Skip to content
Snippets Groups Projects
Commit 75d23c60 authored by jurgenhaas's avatar jurgenhaas
Browse files

Set access token through inventory specific variable and remove the global env...

Set access token through inventory specific variable and remove the global env and default values from new runners
parent 9c208ad5
Branches
No related tags found
No related merge requests found
...@@ -6,18 +6,18 @@ if [[ "$1" == "" ]]; then ...@@ -6,18 +6,18 @@ if [[ "$1" == "" ]]; then
echo "Project ID required as first argument." echo "Project ID required as first argument."
exit 1 exit 1
elif [[ "$1" == "auto" ]]; then elif [[ "$1" == "auto" ]]; then
ID=$(curl -s -H "PRIVATE-TOKEN: {{ lookup('env','GITLAB_ACCESS_TOKEN') }}" "https://gitlab.lakedrops.com/api/v4/projects/?topic=needs_runner_{{ inventory_hostname }}" | jq -r '.[0].id') ID=$(curl -s -H "PRIVATE-TOKEN: {{ gitlab_register_runner_access_token }}" "https://gitlab.lakedrops.com/api/v4/projects/?topic=needs_runner_{{ inventory_hostname }}" | jq -r '.[0].id')
if [[ "$ID" == "null" ]]; then if [[ "$ID" == "null" ]]; then
echo "Nothing to do" echo "Nothing to do"
exit 0 exit 0
fi fi
echo "Adding runner for project ID $ID" echo "Adding runner for project ID $ID"
curl -X PUT -s -H "PRIVATE-TOKEN: {{ lookup('env','GITLAB_ACCESS_TOKEN') }}" "https://gitlab.lakedrops.com/api/v4/projects/${ID}" -d "topics=runner_{{ inventory_hostname }}" curl -X PUT -s -H "PRIVATE-TOKEN: {{ gitlab_register_runner_access_token }}" "https://gitlab.lakedrops.com/api/v4/projects/${ID}" -d "topics=runner_{{ inventory_hostname }}"
else else
ID=$1 ID=$1
fi fi
TOKEN=$(curl -s -X POST -H "PRIVATE-TOKEN: {{ lookup('env','GITLAB_ACCESS_TOKEN') }}" --data "runner_type=project_type" --data "project_id=${ID}" --data "tag_list=deploylocal" "https://gitlab.lakedrops.com/api/v4/user/runners" | jq -r .token) TOKEN=$(curl -s -X POST -H "PRIVATE-TOKEN: {{ gitlab_register_runner_access_token }}" --data "runner_type=project_type" --data "project_id=${ID}" --data "tag_list=deploylocal" "https://gitlab.lakedrops.com/api/v4/user/runners" | jq -r .token)
NAME=$(curl -s -H "PRIVATE-TOKEN: {{ lookup('env','GITLAB_ACCESS_TOKEN') }}" "https://gitlab.lakedrops.com/api/v4/projects/${ID}" | jq -r .path_with_namespace) NAME=$(curl -s -H "PRIVATE-TOKEN: {{ gitlab_register_runner_access_token }}" "https://gitlab.lakedrops.com/api/v4/projects/${ID}" | jq -r .path_with_namespace)
gitlab-runner register --non-interactive --token "${TOKEN}" --name "Local deployment {{ inventory_hostname }}, ${NAME}" --url https://gitlab.lakedrops.com/ --executor docker --docker-image registry.lakedrops.com/docker/gitlab-drupal-ci/php-7.4 --docker-disable-cache --docker-volumes "/var/run/docker.sock:/var/run/docker.sock" --docker-volumes "/drupal/${ID}:/data" --env "DOCKER_AUTH_CONFIG={\"auths\":{\"registry.lakedrops.com\":{\"auth\":\"{{ gitlab_docker_registry_token }}\"}}}" --docker-pull-policy "always" gitlab-runner register --non-interactive --token "${TOKEN}" --name "Local deployment {{ inventory_hostname }}, ${NAME}" --url https://gitlab.lakedrops.com/ --executor docker --docker-image registry.lakedrops.com/docker/gitlab-drupal-ci/php-7.4 --docker-disable-cache --docker-volumes "/var/run/docker.sock:/var/run/docker.sock" --docker-volumes "/drupal/${ID}:/data"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment