|
| 1 | + |
| 2 | +# Use path object to store key files temporarily in module of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info |
| 3 | +resource "local_file" "ansible_inventory" { |
| 4 | + filename = "${path.root}/tmp/ansible_inventory.ini" |
| 5 | + file_permission = "0755" |
| 6 | + content = <<EOF |
| 7 | +# Ansible Inventory Group names must match Ansible Playbooks for SAP - hana_primary, hana_secondary, anydb_primary, anydb_secondary, nwas_ascs, nwas_ers, nwas_pas, nwas_aas |
| 8 | +
|
| 9 | +[hana_primary] |
| 10 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "hana_primary"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 11 | +
|
| 12 | +[hana_secondary] |
| 13 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "hana_secondary"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 14 | +
|
| 15 | +[nwas_ascs] |
| 16 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "nwas_ascs"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 17 | +
|
| 18 | +[nwas_ers] |
| 19 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "nwas_ers"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 20 | +
|
| 21 | +[nwas_pas] |
| 22 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "nwas_pas"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 23 | +
|
| 24 | +[nwas_aas] |
| 25 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "nwas_aas"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 26 | +
|
| 27 | +[anydb_primary] |
| 28 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "anydb_primary"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 29 | +
|
| 30 | +[anydb_secondary] |
| 31 | +${ join(", ", [ for k1 in [for k2,v2 in var.module_var_host_specifications[var.module_var_host_specification_plan] : k2 if v2.sap_host_type == "anydb_secondary"] : format("%s ansible_host=%s ansible_connection=ssh ansible_user=root",k1,var.module_var_host_provision_outputs[k1].output_host_private_ip) ] ) } |
| 32 | +
|
| 33 | +EOF |
| 34 | +} |
0 commit comments