-
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.
Merge pull request #19 from appuio/hiera
Support Puppet-managed LoadBalancers
- Loading branch information
Showing
13 changed files
with
339 additions
and
174 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,19 @@ | ||
name: Pull Request | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Extract Terraform version from constraints in module | ||
run: echo TF_VERSION=$(grep "^[[:space:]]\+required_version = \"" provider.tf | cut -d= -f2- | tr -d ' "') >> $GITHUB_ENV | ||
- uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ${{ env.TF_VERSION }} | ||
- run: terraform fmt -check -recursive | ||
- run: terraform init -input=false | ||
- run: terraform validate |
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,75 @@ | ||
#!/bin/sh | ||
|
||
readonly cluster_id=$1 | ||
readonly branch="tf/lbaas/${cluster_id}" | ||
|
||
cd appuio_hieradata || exit 1 | ||
|
||
git config user.name "${GIT_AUTHOR_NAME}" | ||
git config user.email "${GIT_AUTHOR_EMAIL}" | ||
|
||
# Checkout feature branch | ||
# 1. try to check out as tracking branch from origin | ||
# 2. checkout as new branch | ||
# 3. checkout existing local branch | ||
# For existing local branch, amend existing commit | ||
if ! git checkout -t origin/"${branch}"; then | ||
if ! git checkout -b "${branch}"; then | ||
git checkout "${branch}" | ||
fi | ||
fi | ||
|
||
git add "lbaas/${cluster_id}.yaml" | ||
|
||
status=$(git status --porcelain) | ||
echo "'${status}'" | ||
|
||
commit_message="Update LBaaS hieradata for ${cluster_id}" | ||
push=1 | ||
if [ "${status}" = "M lbaas/${cluster_id}.yaml" ]; then | ||
git commit -m"${commit_message}" | ||
elif [ "${status}" != "" ]; then | ||
# assume new hieradata | ||
commit_message="Create LBaaS hieradata for ${cluster_id}" | ||
git commit -m "${commit_message}" | ||
else | ||
push=0 | ||
fi | ||
|
||
if [ "${push}" -eq 1 ]; then | ||
# Push branch to origin and set upstream | ||
git push origin "${branch}" | ||
fi | ||
|
||
# Always set branch's upstream to origin/master. | ||
# | ||
# If we would set the branch's upstream to the pushed branch, subsequent | ||
# terraform runs break if the upstream branch has been merged or deleted. | ||
# | ||
# If we only set the upstream when pushing, subsequent terraform runs break if | ||
# there's been no changes in the hieradata. | ||
git branch -u origin/master | ||
|
||
# Create MR if none exists yet | ||
open_mrs=$(curl -sH "Authorization: Bearer ${HIERADATA_REPO_TOKEN}" \ | ||
"https://git.vshn.net/api/v4/projects/368/merge_requests?state=opened&source_branch=tf/lbaas/${cluster_id}") | ||
if [ "${push}" -eq 0 ]; then | ||
mr_url="No changes, skipping push and MR creation" | ||
elif [ "${open_mrs}" = "[]" ]; then | ||
# create MR | ||
mr_url=$(curl -XPOST -sH "Authorization: Bearer ${HIERADATA_REPO_TOKEN}" \ | ||
-H"Content-type: application/json" \ | ||
"https://git.vshn.net/api/v4/projects/368/merge_requests" \ | ||
-d \ | ||
"{ | ||
\"id\": 368, | ||
\"source_branch\": \"tf/lbaas/${cluster_id}\", | ||
\"target_branch\": \"master\", | ||
\"title\": \"${commit_message}\", | ||
\"remove_source_branch\": true | ||
}" | jq -r '.web_url') | ||
else | ||
mr_url=$(echo "${open_mrs}" | jq -r '.[0].web_url') | ||
fi | ||
|
||
echo "${mr_url}" > /tf/.mr_url.txt |
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,16 @@ | ||
#!/bin/sh | ||
|
||
set -eo pipefail | ||
|
||
curl -s -X POST -H "X-AccessToken: ${CONTROL_VSHN_NET_TOKEN}" \ | ||
https://control.vshn.net/api/servers/1/appuio/ \ | ||
-d "{ | ||
\"customer\": \"appuio\", | ||
\"fqdn\": \"${SERVER_FQDN}\", | ||
\"location\": \"cloudscale\", | ||
\"region\": \"${SERVER_REGION}\", | ||
\"environment\": \"AppuioLbaas\", | ||
\"project\": \"lbaas\", | ||
\"role\": \"lb\", | ||
\"stage\": \"${CLUSTER_ID}\" | ||
}" |
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
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
4 changes: 2 additions & 2 deletions
4
modules/node-group/versions.tf → modules/node-group/providers.tf
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
terraform { | ||
required_version = ">= 0.14" | ||
required_providers { | ||
cloudscale = { | ||
source = "terraform-providers/cloudscale" | ||
source = "cloudscale-ch/cloudscale" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
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
Oops, something went wrong.