-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration.tf
82 lines (68 loc) · 2.31 KB
/
integration.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#############################################################
# Export Terraform variable values to an Ansible var_file.
#############################################################
#### HA Infra variables.
data "local_file" "input" {
depends_on = [module.cos_clean_up]
filename = "modules/cos/cos_apykey.tmpl"
}
locals {
cos_apikey = chomp(data.local_file.input.content)
}
resource "local_file" "ansible_infra-vars" {
depends_on = [ null_resource.id_rsa_validation , module.cos_clean_up]
file_permission = "0644"
content = <<-DOC
---
# Ansible vars_file containing variable values passed from Terraform.
# Generated by "terraform plan&apply" command.
# INFRA variables
api_key: ${local.cos_apikey}
region: "${var.REGION}"
resource_instance_id: "${data.ibm_resource_key.key.resource_instance_id}"
bucket: "${local.hana_sid}-hana-backup-bucket"
endpoint_url: "${data.ibm_cos_bucket.regional_cos_bucket.s3_endpoint_direct}"
# HANA VSIs
ha_cluster: "${var.HA_CLUSTER}"
db_hostname_1: "${var.DB_HOSTNAME_1}"
db_private_ip_1: "${data.ibm_is_instance.db-vsi-1.primary_network_interface[0].primary_ip[0].address}"
db_hostname_2: "${var.DB_HOSTNAME_2}"
db_private_ip_2: "${local.db-vsi-2-ansible}"
...
DOC
filename = "ansible/infra-vars.yml"
}
#### Ansible inventory.
resource "local_file" "ansible_inventory" {
depends_on = [ local_file.ansible_infra-vars ]
file_permission = "0644"
content = <<-DOC
all:
hosts:
db_private_ip_1:
ansible_host: "${data.ibm_is_instance.db-vsi-1.primary_network_interface[0].primary_ip[0].address}"
db_private_ip_2:
ansible_host: "${local.db-vsi-2-ansible}"
DOC
filename = "ansible/inventory.yml"
}
#### HANADB variables.
resource "local_file" "db_ansible_saphana-vars" {
depends_on = [ local_file.ansible_inventory ]
file_permission = "0644"
content = <<-DOC
---
# Ansible vars_file containing variable values passed from Terraform.
# enerated by "terraform plan&apply" command.
# HANA DB configuration
hana_sid: "${var.HANA_SID}"
hana_sysno: "${var.HANA_SYSNO}"
hana_tenants: "${join(",", var.HANA_TENANTS)}"
hana_main_password: "${var.HANA_MAIN_PASSWORD}"
hana_kit_for_backint_cos: "${var.HANA_KIT_FOR_BACKINT_COS}"
backint_cos_kit: "${var.BACKINT_COS_KIT}"
create_hdbbackint_script: "${var.CREATE_HDBBACKINT_SCRIPT}"
...
DOC
filename = "ansible/saphana-vars.yml"
}