forked from cloud-ca/cloudca-rke-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample gitlab ci and circleci config (cloud-ca#2)
- Loading branch information
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
_defaults: &defaults | ||
docker: | ||
- image: hashicorp/terraform:0.12.4 | ||
|
||
_run: | ||
setenv: &setenv | ||
name: "Setup Environment" | ||
command: |- | ||
apk add --update make curl | ||
curl -sL https://github.com/cloud-ca/terraform-provider-cloudca/releases/download/v1.5.0/terraform-provider-cloudca_v1.5.0_linux-amd64.zip > terraform-provider-cloudca.zip && \ | ||
mkdir -p ~/.terraform.d/plugins && \ | ||
unzip -q terraform-provider-cloudca.zip -d ~/.terraform.d/plugins && \ | ||
rm terraform-provider-cloudca.zip | ||
terraform --version | ||
make init | ||
version: 2 | ||
jobs: | ||
validate: | ||
<<: *defaults | ||
steps: | ||
- run: *setenv | ||
- run: | ||
name: "Validate Terraform configs" | ||
command: make validate | ||
|
||
checkfmt: | ||
<<: *defaults | ||
steps: | ||
- run: *setenv | ||
- run: | ||
name: "Check formatting of all tf files" | ||
command: make checkfmt | ||
|
||
plan: | ||
<<: *defaults | ||
steps: | ||
- run: *setenv | ||
- run: | ||
name: "Plan the Terraform config" | ||
command: TFPLAN=terraform.tfplan make plan | ||
- save_cache: | ||
key: terraform-tfplan-{{ .Environment.CIRCLE_SHA1 }} | ||
paths: | ||
- terraform.tfplan | ||
|
||
apply: | ||
<<: *defaults | ||
steps: | ||
- restore_cache: | ||
key: terraform-tfplan-{{ .Environment.CIRCLE_SHA1 }} | ||
- run: *setenv | ||
- run: | ||
name: "Apply the Terraform config" | ||
command: TFPLAN=terraform.tfplan make apply | ||
|
||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- validate: | ||
filters: | ||
tags: | ||
only: /v.*/ | ||
- checkfmt: | ||
filters: | ||
tags: | ||
only: /v.*/ | ||
- plan: | ||
requires: | ||
- validate | ||
- checkfmt | ||
filters: | ||
tags: | ||
only: /v.*/ | ||
- apply: | ||
requires: | ||
- plan | ||
filters: | ||
tags: | ||
only: /v.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
image: | ||
name: hashicorp/terraform:0.12.4 | ||
entrypoint: | ||
- '/usr/bin/env' | ||
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' | ||
|
||
stages: | ||
- validate | ||
- plan | ||
- deploy | ||
|
||
variables: | ||
PLAN: terraform.tfplan | ||
|
||
cache: | ||
paths: | ||
- .terraform | ||
|
||
before_script: | ||
- apk add --update make curl | ||
- | | ||
curl -sL https://github.com/cloud-ca/terraform-provider-cloudca/releases/download/v1.5.0/terraform-provider-cloudca_v1.5.0_linux-amd64.zip > terraform-provider-cloudca.zip && \ | ||
mkdir -p ~/.terraform.d/plugins && \ | ||
unzip -q terraform-provider-cloudca.zip -d ~/.terraform.d/plugins && \ | ||
rm terraform-provider-cloudca.zip | ||
- terraform --version | ||
- make init | ||
|
||
validate: | ||
stage: validate | ||
script: | ||
- make validate | ||
|
||
checkfmt: | ||
stage: validate | ||
script: | ||
- make checkfmt | ||
|
||
plan: | ||
stage: plan | ||
script: | ||
- TFPLAN=$PLAN make plan | ||
artifacts: | ||
name: plan | ||
paths: | ||
- $PLAN | ||
|
||
apply: | ||
stage: deploy | ||
environment: | ||
name: prod | ||
script: | ||
- TFPLAN=$PLAN make apply | ||
dependencies: | ||
- plan | ||
when: manual | ||
only: | ||
- master |