forked from datadarius/tf-aks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml.disabled
147 lines (130 loc) · 4.15 KB
/
.gitlab-ci.yml.disabled
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Official image for Hashicorp's Terraform. It uses light image which is Alpine
# based as it is much lighter.
#
# Entrypoint is also needed as image by default set `terraform` binary as an
# entrypoint.
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
# Default output file for Terraform plan
variables:
PLAN: plan.tfplan
TF_VAR_FILE: test.tf-test
BUILD_PATH_BOOTSTRAP_AZURE_REMOTE_STATE: /builds/datadarius/tf-aks/bootstrap-azure-remote-state
BUILD_PATH_AZURE_KUBERNETES_SERVICE: /builds/datadarius/tf-aks/terraform-azure-kubernetes-service
cache:
paths:
- .terraform
before_script:
- export ARM_CLIENT_ID=$client_id && export ARM_CLIENT_SECRET=$client_secret && export ARM_TENANT_ID=$tenant_id && export ARM_SUBSCRIPTION_ID=$subscription_id
stages:
- validate
- docs
- plan
- apply
- inspec_test
- destroy
validate-bootstrap-azure-remote-state:
stage: validate
script:
- cd $BUILD_PATH_BOOTSTRAP_AZURE_REMOTE_STATE
- terraform init
- terraform validate -var-file=$TF_VAR_FILE -input=false
artifacts:
name: terraformdata
paths:
- .terraform
plan-bootstrap-azure-remote-state:
stage: plan
dependencies:
- validate-bootstrap-azure-remote-state
script:
- cd $BUILD_PATH_BOOTSTRAP_AZURE_REMOTE_STATE
- terraform init
- terraform plan -var-file=$TF_VAR_FILE -input=false -out=$PLAN
artifacts:
name: $PLAN
paths:
- $BUILD_PATH_BOOTSTRAP_AZURE_REMOTE_STATE
- .terraform
apply-bootstrap-azure-remote-state:
stage: apply
dependencies:
- plan-bootstrap-azure-remote-state
script:
- cd $BUILD_PATH_BOOTSTRAP_AZURE_REMOTE_STATE
- terraform init
- terraform apply -input=false $PLAN
- terraform destroy -var-file=$TF_VAR_FILE -input=false -force
only:
- master
# inspec_test:
# stage: inspec_test
# script:
# - 'echo gem: --no-document > $HOME/.gemrc'
# - apk update
# - apk add build-base git libffi-dev ruby-dev ruby-bundler
# - gem install inspec
# - inspec exec my-profile -t azure://
# - terraform destroy -input=false
validate-terraform-azure-kubernetes-service:
stage: validate
script:
- cd $BUILD_PATH_AZURE_KUBERNETES_SERVICE
- terraform init
- terraform validate -var-file=$TF_VAR_FILE -var 'service_principal=$client_id' -var 'service_principal_secret=$client_secret' -input=false
artifacts:
name: terraformdata2
paths:
- .terraform
plan-terraform-azure-kubernetes-service:
stage: plan
dependencies:
- validate-terraform-azure-kubernetes-service
script:
- cd $BUILD_PATH_AZURE_KUBERNETES_SERVICE
- terraform init
- terraform plan -var-file=$TF_VAR_FILE -var 'service_principal=$client_id' -var 'service_principal_secret=$client_secret' -input=false -out=$PLAN
artifacts:
name: PLAN
paths:
- $BUILD_PATH_AZURE_KUBERNETES_SERVICE
- plan.tfplan
apply-terraform-azure-kubernetes-service:
stage: apply
dependencies:
- plan-terraform-azure-kubernetes-service
script:
- cd $BUILD_PATH_AZURE_KUBERNETES_SERVICE
- terraform init
- terraform apply -input=false $PLAN
- terraform destroy -var-file=$TF_VAR_FILE -var 'service_principal=$client_id' -var 'service_principal_secret=$client_secret' -input=false -force
when: manual
only:
- master
terraform-docs:
image: registry.gitlab.com/datadarius/docker-terraform-docs:latest
stage: docs
dependencies:
- validate-terraform-azure-kubernetes-service
script:
- cd $BUILD_PATH_AZURE_KUBERNETES_SERVICE
- terraform-docs md . > terraform-info.md
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git add terraform-info.md
- git commit terraform-info.md -m "terraform-docs from gitlab runner"
when: manual
only:
- master
# inspec_test:
# stage: inspec_test
# script:
# - 'echo gem: --no-document > $HOME/.gemrc'
# - apk update
# - apk add build-base git libffi-dev ruby-dev ruby-bundler
# - gem install inspec
# - inspec exec my-profile -t azure://
# - terraform destroy -input=false