Skip to content

Commit e6ca669

Browse files
author
Steven Stringer
authored
Merge pull request #76 from SUSE/add-sles-12-for-aws
Fixed AWS SLES 12 support
2 parents 8758187 + dba9080 commit e6ca669

5 files changed

Lines changed: 64 additions & 18 deletions

File tree

terraform/aws/inventory.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ all:
55
%{ for index, value in hana-pip ~}
66
${hana_hostname}${format("%02d", index + 1)}:
77
ansible_host: ${value}
8-
ansible_python_interpreter: /usr/bin/python3
8+
%{ if hana-major-version == "12" }ansible_python_interpreter: /usr/bin/python2.7%{ else }ansible_python_interpreter: /usr/bin/python3 %{ endif }
99
%{ endfor ~}
1010
%{ if iscsi-enabled }
1111
iscsi:
1212
hosts:
1313
%{ for index, value in iscsi-pip ~}
1414
${iscsi_hostname}${format("%02d", index + 1)}:
1515
ansible_host: ${value}
16-
ansible_python_interpreter: /usr/bin/python3
16+
%{ if iscsi-major-version == "12" }ansible_python_interpreter: /usr/bin/python2.7%{ else }ansible_python_interpreter: /usr/bin/python3%{ endif }
1717
%{ endfor ~}
1818
%{ endif }
1919
hosts: null

terraform/aws/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ locals {
5656
netweaver_os_image = var.netweaver_os_image != "" ? var.netweaver_os_image : var.os_image
5757
netweaver_os_owner = var.netweaver_os_owner != "" ? var.netweaver_os_owner : var.os_owner
5858

59+
60+
# For SLES 12 we need to instruct ansible to use python2.7 and for SLES 15 it's python3.
61+
# These locals calculate the major version of the os from the OS image but assumes the OS image format is consistent
62+
# The regex is only used if the var.x_os_major is not set, so if the regex is failing, the user can manually set their major OS.
63+
hana_major_version = var.hana_os_major_version != "" ? var.hana_os_major_version : regex("-([0-9]+)-", local.hana_os_image)[0]
64+
iscsi_major_version = var.iscsi_os_major_version != "" ? var.iscsi_os_major_version : regex("-([0-9]+)-", local.iscsi_os_image)[0]
65+
monitoring_major_version = var.monitoring_os_major_version != "" ? var.monitoring_os_major_version : regex("-([0-9]+)-", local.monitoring_os_image)[0]
66+
drbd_major_version = var.drdb_os_major_version != "" ? var.drdb_os_major_version : regex("-([0-9]+)-", local.drbd_os_image)[0]
67+
netweaver_major_version = var.netweaver_os_major_version != "" ? var.netweaver_os_major_version : regex("-([0-9]+)-", local.netweaver_os_image)[0]
68+
5969
# Netweaver password checking
6070
# If Netweaver is not enabled, a dummy password is passed to pass the variable validation and not require
6171
# a password in this case

terraform/aws/outputs.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ output "netweaver_public_name" {
9898
resource "local_file" "ansible_inventory" {
9999
content = templatefile("inventory.tmpl",
100100
{
101-
hana_hostname = var.hana_name,
102-
hana-pip = module.hana_node.hana_public_ip,
103-
iscsi_hostname = var.iscsi_name,
104-
iscsi-pip = module.iscsi_server.iscsisrv_public_ip,
105-
iscsi-enabled = local.iscsi_enabled
101+
hana_hostname = var.hana_name,
102+
hana-pip = module.hana_node.hana_public_ip,
103+
hana-major-version = local.hana_major_version,
104+
iscsi_hostname = var.iscsi_name,
105+
iscsi-pip = module.iscsi_server.iscsisrv_public_ip,
106+
iscsi-enabled = local.iscsi_enabled,
107+
iscsi-major-version = local.iscsi_major_version
106108
})
107109
filename = "inventory.yaml"
108110
}

terraform/aws/variables.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,3 +851,37 @@ variable "pre_deployment" {
851851
type = bool
852852
default = false
853853
}
854+
855+
#Different versions of python are used by ansible in SLES 12 and SLES 15. The code will try and indetify the correct
856+
#version of SLES installed and select the appropriate version of the python interpretor for the inventory.yaml file
857+
#SLES 12 needs to user 2.7 and SLES 15 uses 3.0.
858+
#However, if the automatic selection proves problematic, the following values can be used as overrides
859+
variable "hana_os_major_version" {
860+
description = "The major OS version of SLES for the HANA VMs. If not set, this value will be computed. Example: 15"
861+
type = string
862+
default = ""
863+
}
864+
865+
variable "iscsi_os_major_version" {
866+
description = "The major OS version of SLES for the iscsi VMs. If not set, this value will be computed. Example: 15"
867+
type = string
868+
default = ""
869+
}
870+
871+
variable "monitoring_os_major_version" {
872+
description = "The major OS version of SLES for the monitoring VMs. If not set, this value will be computed. Example: 15"
873+
type = string
874+
default = ""
875+
}
876+
877+
variable "drdb_os_major_version" {
878+
description = "The major OS version of SLES for the drdb VMs. If not set, this value will be computed. Example: 15"
879+
type = string
880+
default = ""
881+
}
882+
883+
variable "netweaver_os_major_version" {
884+
description = "The major OS version of SLES for the netweaver VMs. If not set, this value will be computed. Example: 15"
885+
type = string
886+
default = ""
887+
}

terraform/libvirt/main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ resource "libvirt_cloudinit_disk" "userdata" {
6464

6565

6666
module "common_variables" {
67-
source = "../generic_modules/common_variables"
68-
provider_type = "libvirt"
69-
deployment_name = local.deployment_name
70-
deployment_name_in_hostname = var.deployment_name_in_hostname
71-
reg_code = var.reg_code
72-
reg_email = var.reg_email
73-
reg_additional_modules = var.reg_additional_modules
74-
ha_sap_deployment_repo = var.ha_sap_deployment_repo
75-
additional_packages = var.additional_packages
76-
authorized_keys = var.authorized_keys
77-
authorized_user = "root"
67+
source = "../generic_modules/common_variables"
68+
provider_type = "libvirt"
69+
deployment_name = local.deployment_name
70+
deployment_name_in_hostname = var.deployment_name_in_hostname
71+
reg_code = var.reg_code
72+
reg_email = var.reg_email
73+
reg_additional_modules = var.reg_additional_modules
74+
ha_sap_deployment_repo = var.ha_sap_deployment_repo
75+
additional_packages = var.additional_packages
76+
authorized_keys = var.authorized_keys
77+
authorized_user = "root"
7878
/*
7979
provisioner = var.provisioner
8080
provisioning_log_level = var.provisioning_log_level

0 commit comments

Comments
 (0)