From 4e6e0a48b813b404cdc733d7f619a8c505cc02b8 Mon Sep 17 00:00:00 2001 From: Ruben Koster Date: Tue, 13 Nov 2018 16:27:20 +0100 Subject: [PATCH] Use internal db for PAS 2.3 --- src/omg-cli/config/terraform_config.go | 14 --- src/omg-cli/omg/tiles/ert/configuration.go | 78 ++----------- src/omg-tf/external_database/ert_database.tf | 103 ------------------ .../external_database/opsman_database.tf | 2 +- src/omg-tf/external_database/outputs.tf | 17 --- src/omg-tf/outputs.tf | 17 --- 6 files changed, 13 insertions(+), 218 deletions(-) delete mode 100644 src/omg-tf/external_database/ert_database.tf diff --git a/src/omg-cli/config/terraform_config.go b/src/omg-cli/config/terraform_config.go index d9b5f8b3..eebf00d0 100644 --- a/src/omg-cli/config/terraform_config.go +++ b/src/omg-cli/config/terraform_config.go @@ -22,7 +22,6 @@ import ( "fmt" "io/ioutil" "path/filepath" - "strconv" ) type TerraformConfigSchema struct { @@ -34,14 +33,9 @@ type TerraformConfigSchema struct { OpsManagerServiceAccountKey string - ExternalSqlIp string `json:"sql_db_ip"` - ExternalSqlPort int OpsManagerSqlDbName string `json:"opsman_sql_db_name"` OpsManagerSqlUsername string `json:"opsman_sql_username"` OpsManagerSqlPassword string `json:"opsman_sql_password"` - ERTSqlDbName string `json:"ert_sql_db_name"` - ERTSqlUsername string `json:"ert_sql_username"` - ERTSqlPassword string `json:"ert_sql_password"` MgmtSubnetName string `json:"management_subnet_name"` MgmtSubnetGateway string `json:"management_subnet_gateway"` @@ -135,14 +129,6 @@ func fromTerraform(filename string) (*Config, error) { hydratedCfg.OpsManager.SkipSSLVerification = true } - if val := flattened["sql_db_port"]; val != "" { - parsed, err := strconv.ParseInt(val, 10, 0) - if err != nil { - return nil, err - } - hydratedCfg.ExternalSqlPort = int(parsed) - } - hydratedCfg.OpsManagerServiceAccountKey = decode(flattened["ops_manager_service_account_key_base64"]) hydratedCfg.ServiceBrokerServiceAccountKey = decode(flattened["service_broker_service_account_key_base64"]) hydratedCfg.StackdriverNozzleServiceAccountKey = decode(flattened["stackdriver_service_account_key_base64"]) diff --git a/src/omg-cli/omg/tiles/ert/configuration.go b/src/omg-cli/omg/tiles/ert/configuration.go index de02f9b7..a687fa0c 100644 --- a/src/omg-cli/omg/tiles/ert/configuration.go +++ b/src/omg-cli/omg/tiles/ert/configuration.go @@ -41,42 +41,16 @@ type Properties struct { // UAA ServiceProviderCredentials tiles.OldCertificateValue `json:".uaa.service_provider_key_credentials"` - UaaDbChoice tiles.Value `json:".properties.uaa_database"` - UaaDbIp tiles.Value `json:".properties.uaa_database.external.host"` - UaaDbPort tiles.IntegerValue `json:".properties.uaa_database.external.port"` - UaaDbUsername tiles.Value `json:".properties.uaa_database.external.uaa_username"` - UaaDbPassword tiles.SecretValue `json:".properties.uaa_database.external.uaa_password"` + UaaDbChoice tiles.Value `json:".properties.uaa_database"` // Databases - ErtDbChoice tiles.Value `json:".properties.system_database"` - ErtDbIp tiles.Value `json:".properties.system_database.external.host"` - ErtDbPort tiles.IntegerValue `json:".properties.system_database.external.port"` - - ErtDbAppUsageUsername tiles.Value `json:".properties.system_database.external.app_usage_service_username"` - ErtDbAppUsagePassword tiles.SecretValue `json:".properties.system_database.external.app_usage_service_password"` - ErtDbAutoscaleUsername tiles.Value `json:".properties.system_database.external.autoscale_username"` - ErtDbAutoscalePassword tiles.SecretValue `json:".properties.system_database.external.autoscale_password"` - ErtDbCloudControllerUsername tiles.Value `json:".properties.system_database.external.ccdb_username"` - ErtDbCloudControllerPassword tiles.SecretValue `json:".properties.system_database.external.ccdb_password"` - ErtDbDiegoUsername tiles.Value `json:".properties.system_database.external.diego_username"` - ErtDbDiegoPassword tiles.SecretValue `json:".properties.system_database.external.diego_password"` - ErtDbLocketUsername tiles.Value `json:".properties.system_database.external.locket_username"` - ErtDbLocketPassword tiles.SecretValue `json:".properties.system_database.external.locket_password"` - ErtDbNetworkPolicyServerUsername tiles.Value `json:".properties.system_database.external.networkpolicyserver_username"` - ErtDbNetworkPolicyServerPassword tiles.SecretValue `json:".properties.system_database.external.networkpolicyserver_password"` - ErtDbNfsUsername tiles.Value `json:".properties.system_database.external.nfsvolume_username"` - ErtDbNfsPassword tiles.SecretValue `json:".properties.system_database.external.nfsvolume_password"` - ErtDbNotificationsUsername tiles.Value `json:".properties.system_database.external.notifications_username"` - ErtDbNotificationsPassword tiles.SecretValue `json:".properties.system_database.external.notifications_password"` - ErtDbAccountUsername tiles.Value `json:".properties.system_database.external.account_username"` - ErtDbAccountPassword tiles.SecretValue `json:".properties.system_database.external.account_password"` - ErtDbRoutingUsername tiles.Value `json:".properties.system_database.external.routing_username"` - ErtDbRoutingPassword tiles.SecretValue `json:".properties.system_database.external.routing_password"` - ErtDbSilkUsername tiles.Value `json:".properties.system_database.external.silk_username"` - ErtDbSilkPassword tiles.SecretValue `json:".properties.system_database.external.silk_password"` + ErtDbChoice tiles.Value `json:".properties.system_database"` // MySQL MySqlMonitorRecipientEmail tiles.Value `json:".mysql_monitor.recipient_email"` + + // Credhub + CredhubDbChoice tiles.Value `json:".properties.credhub_database"` } type LargeFootprintResources struct { @@ -155,37 +129,9 @@ func (*Tile) Configure(envConfig *config.EnvConfig, cfg *config.Config, om *ops_ SecurityAcknowledgement: tiles.Value{"X"}, ServiceProviderCredentials: tiles.OldCertificateValue{tiles.Certificate{cfg.SslCertificate, cfg.SslPrivateKey}}, - UaaDbChoice: tiles.Value{"external"}, - UaaDbIp: tiles.Value{cfg.ExternalSqlIp}, - UaaDbPort: tiles.IntegerValue{cfg.ExternalSqlPort}, - UaaDbUsername: tiles.Value{cfg.ERTSqlUsername}, - UaaDbPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - - ErtDbChoice: tiles.Value{"external"}, - ErtDbIp: tiles.Value{cfg.ExternalSqlIp}, - ErtDbPort: tiles.IntegerValue{cfg.ExternalSqlPort}, - ErtDbAppUsageUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbAppUsagePassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbAutoscaleUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbAutoscalePassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbCloudControllerUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbCloudControllerPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbDiegoUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbDiegoPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbLocketUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbLocketPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbNetworkPolicyServerUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbNetworkPolicyServerPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbNfsUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbNfsPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbNotificationsUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbNotificationsPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbAccountUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbAccountPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbRoutingUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbRoutingPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, - ErtDbSilkUsername: tiles.Value{cfg.ERTSqlUsername}, - ErtDbSilkPassword: tiles.SecretValue{tiles.Secret{cfg.ERTSqlPassword}}, + UaaDbChoice: tiles.Value{"internal_mysql"}, + ErtDbChoice: tiles.Value{"internal_pxc"}, + CredhubDbChoice: tiles.Value{"internal_mysql"}, MySqlMonitorRecipientEmail: tiles.Value{"admin@example.org"}, } @@ -216,7 +162,7 @@ func (*Tile) Configure(envConfig *config.EnvConfig, cfg *config.Config, om *ops_ InternetConnected: false, }, HaProxy: tiles.Resource{Instances: &zero}, - MysqlMonitor: tiles.Resource{Instances: &zero}, + MysqlMonitor: tiles.Resource{Instances: &one}, } // Healthwatch pushes quite a few apps, make sure we have enough compute if envConfig.IncludeHealthwatch { @@ -241,9 +187,9 @@ func (*Tile) Configure(envConfig *config.EnvConfig, cfg *config.Config, om *ops_ InternetConnected: false, }, HaProxy: tiles.Resource{Instances: &zero}, - MysqlProxy: tiles.Resource{Instances: &zero}, - Mysql: tiles.Resource{Instances: &zero}, - MysqlMonitor: tiles.Resource{Instances: &zero}, + MysqlProxy: tiles.Resource{Instances: &one}, + Mysql: tiles.Resource{Instances: &one}, + MysqlMonitor: tiles.Resource{Instances: &one}, } resourcesBytes, err = json.Marshal(&resources) } diff --git a/src/omg-tf/external_database/ert_database.tf b/src/omg-tf/external_database/ert_database.tf deleted file mode 100644 index ed95a8af..00000000 --- a/src/omg-tf/external_database/ert_database.tf +++ /dev/null @@ -1,103 +0,0 @@ -resource "google_sql_database" "uaa" { - name = "uaa" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_user.ert", "google_sql_user.opsman"] - - count = "${var.count}" -} - -resource "google_sql_database" "ccdb" { - name = "ccdb" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.uaa"] - - count = "${var.count}" -} - -resource "google_sql_database" "notifications" { - name = "notifications" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.ccdb"] - - count = "${var.count}" -} - -resource "google_sql_database" "autoscale" { - name = "autoscale" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.notifications"] - - count = "${var.count}" -} - -resource "google_sql_database" "app_usage_service" { - name = "app_usage_service" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.autoscale"] - - count = "${var.count}" -} - -resource "google_sql_database" "console" { - name = "console" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.app_usage_service"] - - count = "${var.count}" -} - -resource "google_sql_database" "diego" { - name = "diego" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.console"] - - count = "${var.count}" -} - -resource "google_sql_database" "routing" { - name = "routing" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.diego"] - - count = "${var.count}" -} - -resource "google_sql_database" "account" { - name = "account" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.routing"] - - count = "${var.count}" -} - -resource "google_sql_database" "networkpolicyserver" { - name = "networkpolicyserver" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.account"] - - count = "${var.count}" -} - -resource "google_sql_database" "nfsvolume" { - name = "nfsvolume" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.networkpolicyserver"] - - count = "${var.count}" -} - -resource "google_sql_database" "locket" { - name = "locket" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.nfsvolume"] - - count = "${var.count}" -} - -resource "google_sql_database" "silk" { - name = "silk" - instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.locket"] - - count = "${var.count}" -} diff --git a/src/omg-tf/external_database/opsman_database.tf b/src/omg-tf/external_database/opsman_database.tf index aacdf0db..035f019a 100644 --- a/src/omg-tf/external_database/opsman_database.tf +++ b/src/omg-tf/external_database/opsman_database.tf @@ -1,7 +1,7 @@ resource "google_sql_database" "opsman" { name = "${var.env_name}" instance = "${google_sql_database_instance.master.name}" - depends_on = ["google_sql_database.nfsvolume"] + depends_on = [] count = "${var.count}" } diff --git a/src/omg-tf/external_database/outputs.tf b/src/omg-tf/external_database/outputs.tf index b3c3d9c9..7209e068 100644 --- a/src/omg-tf/external_database/outputs.tf +++ b/src/omg-tf/external_database/outputs.tf @@ -2,10 +2,6 @@ output "sql_db_port" { value = "3306" } -output "sql_db_ip" { - value = "${google_sql_database_instance.master.0.ip_address.0.ip_address}" -} - output "opsman_sql_db_name" { value = "${google_sql_database.opsman.0.name}" } @@ -18,16 +14,3 @@ output "opsman_sql_password" { sensitive = true value = "${random_id.opsman_db_password.0.b64}" } - -output "ert_sql_username" { - value = "${random_id.ert_db_username.0.b64}" -} - -output "ert_sql_password" { - sensitive = true - value = "${random_id.ert_db_password.0.b64}" -} - -output "ip" { - value = "${google_sql_database_instance.master.0.ip_address.0.ip_address}" -} \ No newline at end of file diff --git a/src/omg-tf/outputs.tf b/src/omg-tf/outputs.tf index 58a6d667..49b1fbb1 100644 --- a/src/omg-tf/outputs.tf +++ b/src/omg-tf/outputs.tf @@ -54,14 +54,6 @@ output "network_name" { value = "${google_compute_network.pcf-network.name}" } -output "sql_db_ip" { - value = "${module.external_database.ip}" -} - -output "sql_db_port" { - value = "${module.external_database.sql_db_port}" -} - output "management_subnet_gateway" { value = "${google_compute_subnetwork.management-subnet.gateway_address}" } @@ -154,15 +146,6 @@ output "director_blobstore_bucket" { value = "${google_storage_bucket.director.name}" } -output "ert_sql_username" { - value = "${module.external_database.ert_sql_username}" -} - -output "ert_sql_password" { - value = "${module.external_database.ert_sql_password}" - sensitive = true -} - output "opsman_sql_username" { value = "${module.external_database.opsman_sql_username}" }