Skip to content

Commit

Permalink
fix: Avoid instance metadata conflicts after instance setup (#11)
Browse files Browse the repository at this point in the history
* Ignore changes in the instance metadata, since it is modified by the SAP startup script.

* Added CI config files

* Fix wrong location for files

* Adding CI setup folder

* Remove spaces to make linter happy.

* Remove duplicate declaration that was breaking tests

* We needed a longer project name.

* Fix linter errors

* Change terraform version

* Migrating tf code to tf v0.12 syntax

* "list"

* Fix syntax

* Fixing python formatting

* Too many blank lines

* Adding missing empty line

* Fixing headers

* terraform fmt

* Restore optional external IP configuration (broken with trf v0.12)

* Disable source check on bash files

* Adding default values for unit tests

* Adding default values for unit tests

* Default values for unit tests

* var.public_ip is 1 or 0

* Missing test values

* Fix test IP

* We'll keep the default service accunt for the unit tests. We'll probably fine-tune this in the future.

* Added missing param

* Make sure each test instance has a different name

* Changing the unit test verification to rely on the instance metadata (and give it some more time to complete instasllation)

* Fixing unit test validators

* Removing unnecessary permissions from unit test project

* terraform fmt

* Adding missing white line

* Removing unneeded folder
  • Loading branch information
apsureda authored Mar 17, 2020
1 parent 96bc36d commit a5592c2
Show file tree
Hide file tree
Showing 56 changed files with 1,129 additions and 600 deletions.
2 changes: 0 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,3 @@ suites:
backend: local
controls:
- deployment_validation


41 changes: 41 additions & 0 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 3600s
steps:
- id: prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment']
env:
- 'TF_VAR_org_id=$_ORG_ID'
- 'TF_VAR_folder_id=$_FOLDER_ID'
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
- id: create
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create']
- id: converge
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge']
- id: verify
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify']
- id: destroy
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy']
tags:
- 'ci'
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0'
24 changes: 24 additions & 0 deletions build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
- name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
id: 'lint'
args: ['/usr/local/bin/test_lint.sh']
tags:
- 'ci'
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0'
40 changes: 20 additions & 20 deletions examples/netweaver_simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ provider "google" {

module "gcp_netweaver" {
source = "../../modules/netweaver"
post_deployment_script = "${var.post_deployment_script}"
subnetwork = "${var.subnetwork}"
linux_image_family = "${var.linux_image_family}"
linux_image_project = "${var.linux_image_project}"
post_deployment_script = var.post_deployment_script
subnetwork = var.subnetwork
linux_image_family = var.linux_image_family
linux_image_project = var.linux_image_project
autodelete_disk = "true"
public_ip = "${var.public_ip}"
sap_deployment_debug = "${var.sap_deployment_debug}"
usr_sap_size = "${var.usr_sap_size}"
sap_mnt_size = "${var.sap_mnt_size}"
swap_size = "${var.swap_size}"
instance_name = "${var.instance_name}"
instance_type = "${var.instance_type}"
region = "${var.region}"
network_tags = "${var.network_tags}"
project_id = "${var.project_id}"
zone = "${var.zone}"
service_account_email = "${var.service_account_email}"
boot_disk_size = "${var.boot_disk_size}"
boot_disk_type = "${var.boot_disk_type}"
disk_type = "${var.disk_type}"
startup_script = "${var.startup_script}"
public_ip = var.public_ip
sap_deployment_debug = var.sap_deployment_debug
usr_sap_size = var.usr_sap_size
sap_mnt_size = var.sap_mnt_size
swap_size = var.swap_size
instance_name = var.instance_name
instance_type = var.instance_type
region = var.region
network_tags = var.network_tags
project_id = var.project_id
zone = var.zone
service_account_email = var.service_account_email
boot_disk_size = var.boot_disk_size
boot_disk_type = var.boot_disk_type
disk_type = var.disk_type
startup_script = var.startup_script
}
4 changes: 2 additions & 2 deletions examples/netweaver_simple_example/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

output "instance_name" {
description = "Name of Netweaver instance"
value = "${var.instance_name}"
value = var.instance_name
}

output "zone" {
description = "Compute Engine instance deployment zone"
value = "${var.zone}"
value = var.zone
}
5 changes: 4 additions & 1 deletion examples/netweaver_simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ variable "subnetwork" {
}

variable "network_tags" {
type = "list"
type = list
description = "List of network tags to attach to the instance."
default = []
}

variable "startup_script" {
Expand All @@ -94,8 +95,10 @@ variable "post_deployment_script" {

variable "sap_deployment_debug" {
description = "Debug flag for Netweaver deployment."
default = "false"
}

variable "public_ip" {
description = "Determines whether a public IP address is added to your VM instance."
default = 1
}
60 changes: 30 additions & 30 deletions examples/sap_hana_ha_simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,42 @@

provider "google" {
version = "~> 2.6.0"
region = "${var.region}"
region = var.region
}

module "gcp_sap_hana_ha" {
source = "../../modules/sap_hana_ha"
subnetwork = "${var.subnetwork}"
linux_image_family = "${var.linux_image_family}"
linux_image_project = "${var.linux_image_project}"
instance_type = "${var.instance_type}"
network_tags = "${var.network_tags}"
project_id = "${var.project_id}"
region = "${var.region}"
service_account_email = "${var.service_account_email}"
boot_disk_size = "${var.boot_disk_size}"
boot_disk_type = "${var.boot_disk_type}"
subnetwork = var.subnetwork
linux_image_family = var.linux_image_family
linux_image_project = var.linux_image_project
instance_type = var.instance_type
network_tags = var.network_tags
project_id = var.project_id
region = var.region
service_account_email = var.service_account_email
boot_disk_size = var.boot_disk_size
boot_disk_type = var.boot_disk_type
autodelete_disk = "true"
pd_ssd_size = "${var.pd_ssd_size}"
pd_hdd_size = "${var.pd_hdd_size}"
sap_hana_deployment_bucket = "${var.sap_hana_deployment_bucket}"
pd_ssd_size = var.pd_ssd_size
pd_hdd_size = var.pd_hdd_size
sap_hana_deployment_bucket = var.sap_hana_deployment_bucket
sap_deployment_debug = "false"
post_deployment_script = "${var.post_deployment_script}"
sap_hana_sid = "${var.sap_hana_sid}"
primary_instance_name = "${var.primary_instance_name}"
secondary_instance_name = "${var.secondary_instance_name}"
primary_zone = "${var.primary_zone}"
secondary_zone = "${var.secondary_zone}"
sap_hana_instance_number = "${var.sap_hana_instance_number}"
sap_hana_sidadm_password = "${var.sap_hana_sidadm_password}"
sap_hana_system_password = "${var.sap_hana_system_password}"
post_deployment_script = var.post_deployment_script
sap_hana_sid = var.sap_hana_sid
primary_instance_name = var.primary_instance_name
secondary_instance_name = var.secondary_instance_name
primary_zone = var.primary_zone
secondary_zone = var.secondary_zone
sap_hana_instance_number = var.sap_hana_instance_number
sap_hana_sidadm_password = var.sap_hana_sidadm_password
sap_hana_system_password = var.sap_hana_system_password
sap_hana_sidadm_uid = 900
sap_hana_sapsys_gid = 900
sap_vip = "${var.sap_vip}"
sap_vip_secondary_range = "${var.sap_vip_secondary_range}"
primary_instance_ip = "${var.primary_instance_ip}"
secondary_instance_ip = "${var.secondary_instance_ip}"
sap_vip_internal_address = "${var.sap_vip_internal_address}"
startup_script_1 = "${file(var.startup_script_1)}"
startup_script_2 = "${file(var.startup_script_2)}"
sap_vip = var.sap_vip
sap_vip_secondary_range = var.sap_vip_secondary_range
primary_instance_ip = var.primary_instance_ip
secondary_instance_ip = var.secondary_instance_ip
sap_vip_internal_address = var.sap_vip_internal_address
startup_script_1 = file(var.startup_script_1)
startup_script_2 = file(var.startup_script_2)
}
6 changes: 3 additions & 3 deletions examples/sap_hana_ha_simple_example/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

output "sap_hana_sid" {
description = "SAP Hana SID user"
value = "${var.sap_hana_sid}"
value = var.sap_hana_sid
}

output "primary_instance_name" {
description = "Name of sap primary instance"
value = "${var.primary_instance_name}"
value = var.primary_instance_name
}

output "secondary_instance_name" {
description = "Name of sap secondary instance"
value = "${var.secondary_instance_name}"
value = var.secondary_instance_name
}
2 changes: 0 additions & 2 deletions examples/sap_hana_ha_simple_example/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ sap_hana_sidadm_password = "<password>"
sap_hana_system_password = "<password>"
sap_vip = "10.1.0.24"
sap_vip_secondary_range = ""
sap_hana_scaleout_nodes = 0
instance_count_master = 1
boot_disk_size = 300
boot_disk_type = "pd-ssd"
service_account_email = <service-account-email>
Expand Down
3 changes: 2 additions & 1 deletion examples/sap_hana_ha_simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ variable "service_account_email" {
}

variable "network_tags" {
type = "list"
type = list
description = "List of network tags to attach to the instance."
default = []
}

variable "primary_instance_ip" {
Expand Down
46 changes: 23 additions & 23 deletions examples/sap_hana_simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@

provider "google" {
version = "~> 2.6.0"
region = "${var.region}"
region = var.region
}

module "gcp_sap_hana" {
source = "../../modules/sap_hana"
subnetwork = "${var.subnetwork}"
linux_image_family = "${var.linux_image_family}"
linux_image_project = "${var.linux_image_project}"
instance_name = "${var.instance_name}"
instance_type = "${var.instance_type}"
project_id = "${var.project_id}"
region = "${var.region}"
zone = "${var.zone}"
service_account_email = "${var.service_account_email}"
boot_disk_type = "${var.boot_disk_type}"
boot_disk_size = "${var.boot_disk_size}"
subnetwork = var.subnetwork
linux_image_family = var.linux_image_family
linux_image_project = var.linux_image_project
instance_name = var.instance_name
instance_type = var.instance_type
project_id = var.project_id
region = var.region
zone = var.zone
service_account_email = var.service_account_email
boot_disk_type = var.boot_disk_type
boot_disk_size = var.boot_disk_size
autodelete_disk = "true"
pd_ssd_size = "${var.pd_ssd_size}"
pd_hdd_size = "${var.pd_hdd_size}"
sap_hana_deployment_bucket = "${var.sap_hana_deployment_bucket}"
pd_ssd_size = var.pd_ssd_size
pd_hdd_size = var.pd_hdd_size
sap_hana_deployment_bucket = var.sap_hana_deployment_bucket
sap_deployment_debug = "false"
post_deployment_script = "${var.post_deployment_script}"
startup_script = "${file(var.startup_script)}"
sap_hana_sid = "${var.sap_hana_sid}"
sap_hana_instance_number = "${var.sap_hana_instance_number}"
sap_hana_sidadm_password = "${var.sap_hana_sidadm_password}"
sap_hana_system_password = "${var.sap_hana_system_password}"
network_tags = "${var.network_tags}"
post_deployment_script = var.post_deployment_script
startup_script = file(var.startup_script)
sap_hana_sid = var.sap_hana_sid
sap_hana_instance_number = var.sap_hana_instance_number
sap_hana_sidadm_password = var.sap_hana_sidadm_password
sap_hana_system_password = var.sap_hana_system_password
network_tags = var.network_tags
sap_hana_sidadm_uid = 900
sap_hana_sapsys_gid = 900
address_name = "${var.address_name}"
address_name = var.address_name
}
6 changes: 3 additions & 3 deletions examples/sap_hana_simple_example/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

output "sap_hana_sid" {
description = "SAP Hana SID user"
value = "${var.sap_hana_sid}"
value = var.sap_hana_sid
}

output "instance_name" {
description = "Name of instance"
value = "${var.instance_name}"
value = var.instance_name
}

output "zone" {
description = "Compute Engine instance deployment zone"
value = "${var.zone}"
value = var.zone
}
3 changes: 2 additions & 1 deletion examples/sap_hana_simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ variable "subnetwork" {
}

variable "network_tags" {
type = "list"
type = list
description = "List of network tags to attach to the instance."
default = []
}

variable "sap_hana_deployment_bucket" {
Expand Down
Loading

0 comments on commit a5592c2

Please sign in to comment.