randomize the secrets

This commit is contained in:
galal-hussein 2019-11-27 20:30:56 +02:00
parent 9969dc9cff
commit 93e28126aa
5 changed files with 19 additions and 6 deletions

View File

@ -6,7 +6,7 @@ terraform {
locals { locals {
name = var.name name = var.name
k3s_cluster_secret = "pvc-6476dcaf-73a0-11e9-b8e5-06943b744282" k3s_cluster_secret = var.k3s_cluster_secret
} }
provider "aws" { provider "aws" {

View File

@ -26,3 +26,8 @@ variable "name" {
type = string type = string
description = "Name to identify this cluster" description = "Name to identify this cluster"
} }
variable "k3s_cluster_secret" {
type = string
description = "Cluster secret for k3s cluster registration"
}

View File

@ -1,6 +1,7 @@
## MAIN VARIABLES ## ## MAIN VARIABLES ##
#################### ####################
CLUSTER_NAME="loadtest-k3s" CLUSTER_NAME="loadtest-k3s"
CLUSTER_SECRET=""
DOMAIN_NAME="loadtest.eng.rancher.space" DOMAIN_NAME="loadtest.eng.rancher.space"
ZONE_ID="" ZONE_ID=""
K3S_VERSION="v1.0.0" K3S_VERSION="v1.0.0"
@ -14,7 +15,7 @@ DB_ENGINE="dqlite"
DB_INSTANCE_TYPE="db.m4.4xlarge" DB_INSTANCE_TYPE="db.m4.4xlarge"
DB_NAME="k3s" DB_NAME="k3s"
DB_USERNAME="k3suser" DB_USERNAME="k3suser"
DB_PASSWORD="024d9442b3add64b7ef90655bc302cd8" DB_PASSWORD=""
DB_VERSION=5.7 DB_VERSION=5.7
## K3S SERVER VARIABLES ## ## K3S SERVER VARIABLES ##

View File

@ -51,8 +51,17 @@ config() {
pushd ./server pushd ./server
eval PRIVATE_KEY_PATH=$PRIVATE_KEY_PATH eval PRIVATE_KEY_PATH=$PRIVATE_KEY_PATH
EXPANDED_PRIV_KEY_PATH=`readlink -f $PRIVATE_KEY_PATH` EXPANDED_PRIV_KEY_PATH=`readlink -f $PRIVATE_KEY_PATH`
if [ -z "$DB_PASSWORD" ]; then
# randomize database password
DB_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
fi
if [ -z "$CLUSTER_SECRET" ]; then
# randomize cluster secret
CLUSTER_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
fi
cat <<MAIN > variables.tfvars cat <<MAIN > variables.tfvars
name = "${CLUSTER_NAME}" name = "${CLUSTER_NAME}"
k3s_cluster_secret = "${CLUSTER_SECRET}"
db_instance_type = "${DB_INSTANCE_TYPE}" db_instance_type = "${DB_INSTANCE_TYPE}"
db_name = "${DB_NAME}" db_name = "${DB_NAME}"
db_username = "${DB_USERNAME}" db_username = "${DB_USERNAME}"
@ -80,6 +89,7 @@ extra_ssh_keys = ["${EXTRA_SSH_KEYS}"]
k3s_version = "${K3S_VERSION}" k3s_version = "${K3S_VERSION}"
agent_node_count = ${AGENT_NODE_COUNT} agent_node_count = ${AGENT_NODE_COUNT}
agent_instance_type = "${AGENT_INSTANCE_TYPE}" agent_instance_type = "${AGENT_INSTANCE_TYPE}"
k3s_cluster_secret = "${CLUSTER_SECRET}"
MAIN MAIN
popd popd
} }

View File

@ -19,7 +19,6 @@ variable "prom_worker_node_count" {
} }
variable "k3s_cluster_secret" { variable "k3s_cluster_secret" {
default = "pvc-6476dcaf-73a0-11e9-b8e5-06943b744282"
type = string type = string
description = "Cluster secret for k3s cluster registration" description = "Cluster secret for k3s cluster registration"
} }
@ -66,9 +65,7 @@ variable "db_username" {
default = "postgres" default = "postgres"
} }
variable "db_password" { variable "db_password" {}
default = "b58bf234c4bd0133fc7a92b782e498a6"
}
variable "db_version" {} variable "db_version" {}