Repository navigation
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
66 lines (61 loc) · 3.08 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
66 lines (61 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
steps:
# - id: 'terraform-plan'
# name: us-central1-docker.pkg.dev/itops-playground/container/infractl:latest
# entrypoint: bash
# env:
# - 'INFRACTL_HOME=/infractl'
# - 'VAULT_ADDR=https://itops-playground-vault-01.corp.oreilly.com:8200'
# args:
# - '-c'
# - |
# . <(git log -n1 | egrep '^\s+\w+\:\s\w+' | sed -Eze 's/\s+(\w+):\s(\S+)/: \${\1=\2} export \1;/g')
# if [ -z "$module" ] || [ -z "$env" ]; then
# echo 'missing required entries: module and/or env, check the documentation'
# exit 1
# fi
# token="$(gcloud auth print-identity-token --impersonate-service-account='cloudbuild@itops-playground.iam.gserviceaccount.com' \
# --audiences='vault/cloudbuild-iam' --project="$env" --include-email)"
# vc="$(vault write -field=token auth/gcp/login role='cloudbuild-iam' jwt=$token)"
# mv /infractl/terraform /infractl/terraform-orig
# ln -s /workspace/terraform /infractl/terraform
# cd /infractl
# infractl --vault-token "$vc" terraform plan --module "$module" --env "$env" --upgrade-on-init --force
- id: 'terraform-apply'
name: us-central1-docker.pkg.dev/itops-playground/container/infractl:latest
# waitFor: ['terraform-plan']
entrypoint: bash
env:
- 'INFRACTL_HOME=/infractl'
- 'VAULT_ADDR=https://itops-playground-vault-01.corp.oreilly.com:8200'
args:
- '-c'
- |
cat /etc/hosts
ip addr show
ifconfig -a
# - |
# if [ "$BRANCH_NAME" = "main" ]; then
# . <(git log -n1 | egrep '^\s+\w+\:\s\w+' | sed -Eze 's/\s+(\w+):\s(\S+)/: \${\1=\2} export \1;/g')
# if [ -z "$module" ] || [ -z "$env" ]; then
# echo 'missing required entries: module and/or env, check the documentation'
# exit 1
# fi
# echo "***************************** TERRAFORM APPLY *******************************"
# echo "************ "Runing terraform apply on '$BRANCH_NAME' branch."**************"
# echo "*****************************************************************************"
# token="$(gcloud auth print-identity-token --impersonate-service-account='cloudbuild@itops-playground.iam.gserviceaccount.com' \
# --audiences='vault/cloudbuild-iam' --project="$env" --include-email)"
# vc="$(vault write -field=token auth/gcp/login role='cloudbuild-iam' jwt=$token)"
# mv /infractl/terraform /infractl/terraform-orig
# ln -s /workspace/terraform /infractl/terraform
# cd /infractl
# infractl --vault-token "$vc" terraform apply --module "$module" --env "$env" --upgrade-on-init --force
# else
# echo "***************************** SKIPPING APPLYING ************************************"
# echo "Terraform apply runs only on branch main - skipping apply on '$BRANCH_NAME' branch."
# echo "************************************************************************************"
# fi
logsBucket: gs://logs_cloud_build
options:
pool:
name: 'projects/itops-playground/locations/us-central1/workerPools/itops-playground-cb'