Skip to content

Commit

Permalink
feat(vault): migrate gitlab token (#29995)
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz authored Oct 16, 2024
1 parent 1a47662 commit 91c70dc
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,14 @@ variables:
VCPKG_BLOB_SAS_URL: ci.datadog-agent-buildimages.vcpkg_blob_sas_url # windows-agent
WINGET_PAT: ci.datadog-agent.winget_pat # windows-agent
# End aws ssm variables

# Start vault variables
AGENT_API_KEY_ORG2: agent-api-key-org-2 # agent-devx-infra
AGENT_APP_KEY_ORG2: agent-ci-app-key-org-2 # agent-devx-infra
AGENT_GITHUB_APP: agent-github-app # agent-devx-infra
ATLASSIAN_WRITE: atlassian-write # agent-devx-infra
DOCKER_REGISTRY_RO: dockerhub-readonly # agent-delivery
GITLAB_TOKEN: gitlab-token # agent-devx-infra
INSTALL_SCRIPT_API_KEY_ORG2: install-script-api-key-org-2 # agent-devx-infra
MACOS_GITHUB_APP_1: macos-github-app-one # agent-devx-infra
MACOS_GITHUB_APP_2: macos-github-app-two # agent-devx-infra
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/.pre/cancel-prev-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ cancel-prev-pipelines:
when: never
- when: on_success
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- inv pipeline.auto-cancel-previous-pipelines
6 changes: 3 additions & 3 deletions .gitlab/.pre/gitlab_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_gitlab_configuration:
- !reference [.except_mergequeue]
- !reference [.on_gitlab_changes]
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- inv -e linter.gitlab-ci
- inv -e linter.job-change-path
- inv -e linter.gitlab-change-paths
Expand All @@ -20,7 +20,7 @@ test_gitlab_compare_to:
- !reference [.except_mergequeue]
- !reference [.on_gitlab_changes]
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- !reference [.setup_agent_github_app]
- pip install -r tasks/requirements.txt
- inv pipeline.compare-to-itself
Expand All @@ -37,7 +37,7 @@ compute_gitlab_ci_config:
- git checkout main
- git checkout -
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- mkdir -p artifacts
- inv -e gitlab.compute-gitlab-ci-config --before-file artifacts/before.gitlab-ci.yml --after-file artifacts/after.gitlab-ci.yml --diff-file artifacts/diff.gitlab-ci.yml
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/common/container_publish_job_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
IMG_VARIABLES: ""
IMG_SIGNING: ""
script: # We can't use the 'trigger' keyword on manual jobs, otherwise they can't be run if the pipeline fails and is retried
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- |
if [[ "$BUCKET_BRANCH" == "nightly" && ( "$IMG_SOURCES" =~ "$SRC_AGENT" || "$IMG_SOURCES" =~ "$SRC_DCA" || "$IMG_SOURCES" =~ "$SRC_CWS_INSTRUMENTATION" || "$IMG_VARIABLES" =~ "$SRC_AGENT" || "$IMG_VARIABLES" =~ "$SRC_DCA" || "$IMG_VARIABLES" =~ "$SRC_CWS_INSTRUMENTATION" ) ]]; then
export ECR_RELEASE_SUFFIX="-nightly"
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/install_script_testing/install_script_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_install_script:
tags: ["arch:amd64"]
script:
- set +x
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- export TESTING_APT_URL=$DEB_TESTING_S3_BUCKET
- export TESTING_YUM_URL=$RPM_TESTING_S3_BUCKET
- export TEST_PIPELINE_ID=$CI_PIPELINE_ID
Expand Down
8 changes: 4 additions & 4 deletions .gitlab/internal_image_deploy/internal_image_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ docker_trigger_internal:
TMPL_SRC_REPO: ci/datadog-agent/agent
RELEASE_STAGING: "true"
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- if [ "$BUCKET_BRANCH" = "beta" ] || [ "$BUCKET_BRANCH" = "stable" ]; then TMPL_SRC_REPO="${TMPL_SRC_REPO}-release"; fi
- |
if [ "$BUCKET_BRANCH" = "nightly" ]; then
Expand Down Expand Up @@ -67,7 +67,7 @@ docker_trigger_internal-ot:
TMPL_SRC_REPO: ci/datadog-agent/agent
RELEASE_STAGING: "true"
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- if [ "$BUCKET_BRANCH" = "beta" ] || [ "$BUCKET_BRANCH" = "stable" ]; then TMPL_SRC_REPO="${TMPL_SRC_REPO}-release"; fi
- |
if [ "$BUCKET_BRANCH" = "nightly" ]; then
Expand Down Expand Up @@ -113,7 +113,7 @@ docker_trigger_cluster_agent_internal:
RELEASE_STAGING: "true"
RELEASE_PROD: "true"
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- if [ "$BUCKET_BRANCH" = "beta" ] || [ "$BUCKET_BRANCH" = "stable" ]; then TMPL_SRC_REPO="${TMPL_SRC_REPO}-release"; fi
- |
if [ "$BUCKET_BRANCH" = "nightly" ]; then
Expand Down Expand Up @@ -159,7 +159,7 @@ docker_trigger_cws_instrumentation_internal:
RELEASE_STAGING: "true"
RELEASE_PROD: "true"
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- if [ "$BUCKET_BRANCH" = "beta" ] || [ "$BUCKET_BRANCH" = "stable" ]; then TMPL_SRC_REPO="${TMPL_SRC_REPO}-release"; fi
- |
if [ "$BUCKET_BRANCH" = "nightly" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal_kubernetes_deploy_experimental:
EXPLICIT_WORKFLOWS: "//workflows:beta_builds.agents_nightly.staging-deploy.publish,//workflows:beta_builds.agents_nightly.staging-validate.publish,//workflows:beta_builds.agents_nightly.prod-wait-business-hours.publish,//workflows:beta_builds.agents_nightly.prod-deploy.publish,//workflows:beta_builds.agents_nightly.prod-validate.publish,//workflows:beta_builds.agents_nightly.publish-image-confirmation.publish"
BUNDLE_VERSION_OVERRIDE: "v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}"
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- "inv pipeline.trigger-child-pipeline --project-name DataDog/k8s-datadog-agent-ops --git-ref main
--variable OPTION_AUTOMATIC_ROLLOUT
--variable EXPLICIT_WORKFLOWS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rc_kubernetes_deploy:
EXPLICIT_WORKFLOWS: "//workflows:deploy_rc.agents_rc"
AGENT_IMAGE_TAG: $CI_COMMIT_REF_NAME
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- "inv pipeline.trigger-child-pipeline --project-name DataDog/k8s-datadog-agent-ops --git-ref main
--variable OPTION_AUTOMATIC_ROLLOUT
--variable EXPLICIT_WORKFLOWS
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/kernel_matrix_testing/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
tags: ["arch:amd64"]
before_script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN read_api) || exit $?; export GITLAB_TOKEN
- !reference [.kmt_new_profile]
script:
- !reference [.shared_filters_and_queries]
Expand Down Expand Up @@ -335,6 +335,6 @@ notify_ebpf_complexity_changes:
- python3 -m pip install tabulate # Required for printing the tables
- python3 -m pip install -r tasks/libs/requirements-github.txt
- !reference [.setup_agent_github_app]
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN read_api) || exit $?; export GITLAB_TOKEN
script:
- inv -e ebpf.generate-complexity-summary-for-pr
6 changes: 3 additions & 3 deletions .gitlab/notify/notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ notify:
resource_group: notification
timeout: 15 minutes # Added to prevent a stuck job blocking the resource_group defined above
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_READ_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN read_api) || exit $?; export GITLAB_TOKEN
- DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_API_KEY_ORG2 token) || exit $?; export DD_API_KEY
- python3 -m pip install -r requirements.txt -r tasks/libs/requirements-notifications.txt
- |
Expand Down Expand Up @@ -53,7 +53,7 @@ send_pipeline_stats:
when: always
dependencies: []
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_READ_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN read_api) || exit $?; export GITLAB_TOKEN
- DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_API_KEY_ORG2 token) || exit $?; export DD_API_KEY
- invoke -e notify.send-stats

Expand Down Expand Up @@ -115,7 +115,7 @@ notify_gitlab_ci_changes:

.failure_summary_setup:
- SLACK_API_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SLACK_AGENT_CI_TOKEN) || exit $?; export SLACK_API_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_READ_API_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN read_api) || exit $?; export GITLAB_TOKEN
- DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_API_KEY_ORG2 token) || exit $?; export DD_API_KEY
- python3 -m pip install -r requirements.txt -r tasks/libs/requirements-notifications.txt

Expand Down
2 changes: 1 addition & 1 deletion .gitlab/trigger_release/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# agent-release-management creates pipeline for both Agent 6 and Agent 7
# when triggered with major version 7
- RELEASE_VERSION="$(inv agent.version --major-version 7 --url-safe --omnibus-format)-1" || exit $?; export RELEASE_VERSION
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN) || exit $?; export GITLAB_TOKEN
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api) || exit $?; export GITLAB_TOKEN
- 'inv pipeline.trigger-child-pipeline --project-name "DataDog/agent-release-management" --git-ref "main"
--variable ACTION
--variable AUTO_RELEASE
Expand Down

0 comments on commit 91c70dc

Please sign in to comment.