Skip to content

Commit

Permalink
feat: added scripts to run playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
anaik91 committed Oct 28, 2023
1 parent 8d0e78a commit 4334522
Show file tree
Hide file tree
Showing 3 changed files with 501 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ jobs:

deploy-runtime-plane:
name: Deploy Apigee Hybrid Runtime GKE Platform
runs-on: ubuntu-latest
runs-on: self-hosted
if: github.event_name == 'push'
needs:
- docker-build
- deploy-runtime-plane-gke
- deploy-control-plane
# needs:
# - docker-build
# - deploy-runtime-plane-gke
# - deploy-control-plane
permissions:
contents: 'read'
id-token: 'write'
Expand All @@ -149,6 +149,7 @@ jobs:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_POOL_PROVIDER_NAME }}
service_account: ${{ secrets.SVC_ACCOUNT_EMAIL }}
access_token_lifetime: 300s
create_credentials_file: true

- name: Login to Artifact Registry
uses: docker/login-action@v1
Expand All @@ -157,15 +158,15 @@ jobs:
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- name: Run Terraform
- name: Run Ansible Playbook
id: init
run: |
docker run -v ${{ github.workspace }}:/app \
${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}/ansible-helm-apigee-hybrid-deployer:${{ steps.commit.outputs.short }} \
cd /app && ansible-playbook playbook.yaml --list-tags
bash run_playbook.sh \
${{ github.workspace }} latest
shell: bash
# working-directory: ./test/scripts
working-directory: ./test/scripts

Check failure on line 167 in .github/workflows/testing.yml

View workflow job for this annotation

GitHub Actions / Lint Codebase

167:42 [trailing-spaces] trailing spaces

Check failure on line 167 in .github/workflows/testing.yml

View workflow job for this annotation

GitHub Actions / Lint Codebase

167:42 [trailing-spaces] trailing spaces
env:
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_REGION: ${{ secrets.GCP_REGION }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.auth.outputs.credentials_file_path }}
39 changes: 39 additions & 0 deletions test/scripts/run_playbook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -x
ANSIBLE_DIR="${1}"
GIT_COMMIT_SHORT_ID="$2"
cd "$ANSIBLE_DIR" || exit

# Function to replace a string from a file
function replace_string() {
# Get the search and replacement strings from the user
input_file="$1"
search_string="$2"
replacement_string="$3"
# Replace the string in the file
sed -i "s/$search_string/$replacement_string/g" "$input_file"
}

replace_string "$ANSIBLE_DIR/vars/test.yaml" "_GCP_PROJECT_ID_" "${GCP_PROJECT_ID}"
replace_string "$ANSIBLE_DIR/vars/test.yaml" "_GCP_REGION_" "${GCP_REGION}"

docker run -v "$ANSIBLE_DIR:/app" \
-v "$GOOGLE_APPLICATION_CREDENTIALS:$GOOGLE_APPLICATION_CREDENTIALS" \
-e "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" \
"$GCP_REGION-docker.pkg.dev/$GCP_REGION/$GCP_GAR_REPO/ansible-helm-apigee-hybrid-deployer:$GIT_COMMIT_SHORT_ID" \
/bin/bash -c "cd /app && ansible-playbook playbook.yaml --list-tags"
Loading

0 comments on commit 4334522

Please sign in to comment.