Skip to content

Commit

Permalink
Merge pull request #34 from sean-freeman/structure_fixes
Browse files Browse the repository at this point in the history
sap_vm_provision: structure fixes for anydb ha, hana scale-out, set vars, and initial ha placement groups
  • Loading branch information
sean-freeman authored Jun 19, 2024
2 parents b6ec291 + 5525ac7 commit d4486a1
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 72 deletions.
15 changes: 15 additions & 0 deletions roles/sap_vm_provision/PLATFORM_GUIDANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,18 @@ When VMware vCenter and vSphere clusters with VMware NSX virtualized network ove
N.B. When VMware vCenter and vSphere clusters with direct network subnet IP allocations to the VMXNet network adapter (no VMware NSX network overlays), the above actions may not be required.

</details>


## Notice regarding SAP High Availability and hardware placement strategies

Each Hyperscaler Cloud Service Provider provides a different approach to the placement strategy of a Virtual Machine to the physical/hardware Hypervisor node it runs atop.

The `sap_vm_provision` Ansible Role enforces scope control for this capability, only providing a "spread" placement strategy for the High Availability scenarios. As such the variable used is `sap_vm_provision_<<infrastructure_platform>>_placement_strategy_spread: true/false`.

The following are the equivalent Placement Strategies, commonly referenced as 'Anti-Affinity', in each Infrastructure Platform:

- **AWS EC2 VS Placement Group, Spread (Rack level)** - each VS on different hosts, in different racks with distinct network source and power supply
- **GCP CE VM Placement Policy, Spread** - each VM on different hosts, in different racks with distinct power supply (dual redundancy from different sources)
- **IBM Cloud VS Placement Group Strategy, Power Spread** - each VS on different hosts, in different racks with distinct network source and power supplies (dual redundancy from different sources)
- **IBM Cloud, IBM Power VS Placement Group Colocation Policy, Different Server Spread** - each VS on different hosts, in different racks with distinct network source and power supplies (dual redundancy from different sources)
- **MS Azure VM Availability Set, Fault Domain Spread** - each VM on different hosts, in different racks with distinct network source and power supply
9 changes: 8 additions & 1 deletion roles/sap_vm_provision/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ sap_vm_provision_aws_vpc_subnet_id: "" # if ansible_to_terraform, use "new"
sap_vm_provision_aws_vpc_subnet_create_boolean: "{{ true | default(false) if sap_vm_provision_aws_vpc_subnet_id == 'new' else false }}"
sap_vm_provision_aws_vpc_sg_names: "" # comma-separated, if ansible_to_terraform then ignore this variable
sap_vm_provision_aws_key_pair_name_ssh_host_public_key: ""
sap_vm_provision_aws_placement_resource_name: "sap-placement-spread"
sap_vm_provision_aws_placement_strategy_spread: false

# Google Cloud
sap_vm_provision_gcp_credentials_json: ""
Expand All @@ -147,6 +149,8 @@ sap_vm_provision_gcp_region: "{{ sap_vm_provision_gcp_region_zone[:-2] }}"
sap_vm_provision_gcp_region_zone: ""
sap_vm_provision_gcp_vpc_name: ""
sap_vm_provision_gcp_vpc_subnet_name: ""
sap_vm_provision_gcp_placement_resource_name: "sap-placement-spread"
sap_vm_provision_gcp_placement_strategy_spread: false

# IBM Cloud
sap_vm_provision_ibmcloud_api_key: ""
Expand All @@ -159,6 +163,8 @@ sap_vm_provision_ibmcloud_vpc_name: ""
sap_vm_provision_ibmcloud_vpc_subnet_name: ""
sap_vm_provision_ibmcloud_vpc_sg_names: "" # comma-separated, if ansible_to_terraform then ignore this variable
sap_vm_provision_ibmcloud_key_pair_name_ssh_host_public_key: ""
sap_vm_provision_ibmcloud_placement_resource_name: "sap-placement-spread"
sap_vm_provision_ibmcloud_placement_strategy_spread: false

# IBM Cloud, addendum for IBM Power VS
sap_vm_provision_ibmcloud_powervs_location: ""
Expand All @@ -178,7 +184,8 @@ sap_vm_provision_msazure_location_availability_zone_no: 1
sap_vm_provision_msazure_vnet_name: ""
sap_vm_provision_msazure_vnet_subnet_name: ""
sap_vm_provision_msazure_key_pair_name_ssh_host_public_key: ""

sap_vm_provision_msazure_placement_resource_name: "sap-placement-spread"
sap_vm_provision_msazure_placement_strategy_spread: false

####
# Infrastructure Platform - Cloud Hyperscaler - High Availability resources
Expand Down
31 changes: 16 additions & 15 deletions roles/sap_vm_provision/tasks/common/set_ansible_vars.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
---

# Required when defining Ansible Role variables within the host_specifications_dictionary for multiple SAP Systems / SAP Landscapes
- name: Set facts for all hosts - use facts from localhost - SAP Variables from host_specifications_dictionary
ansible.builtin.set_fact:
"{{ host_spec_sap_item }}": "{{ lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary')[sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default(inventory_hostname)][host_spec_sap_item] }}"
loop: "{{ vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default(inventory_hostname)].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list }}"
loop_control:
loop_var: host_spec_sap_item

- name: Set facts for all hosts - use facts from localhost - Host Specifications Dictionary
ansible.builtin.set_fact:
host_specifications_dictionary: "{{ lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary') }}"


- name: Set facts for all hosts - use facts from localhost - Generic
ansible.builtin.set_fact:
sap_vm_provision_dns_root_domain: "{{ sap_vm_provision_dns_root_domain }}"
Expand All @@ -22,13 +35,13 @@

- name: Set facts for all hosts - use facts from localhost - SAP HANA
ansible.builtin.set_fact:
sap_hana_sid: "{{ sap_hana_sid | default(sap_system_hana_db_sid) }}"
sap_hana_install_sid: "{{ sap_hana_install_sid | default(sap_system_hana_db_sid) }}"
sap_hana_install_instance_nr: "{{ sap_hana_install_instance_nr | default(sap_system_hana_db_instance_nr) }}"
sap_hana_install_use_master_password: "{{ sap_hana_install_use_master_password | default('y') }}"
sap_hana_install_master_password: "{{ sap_hana_install_master_password | default('') }}"
sap_hana_install_software_directory: "{{ sap_software_download_directory | default('/software') }}"
when:
- (sap_hana_sid is defined or sap_system_hana_db_sid is defined) or (hostvars[inventory_hostname].vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][inventory_hostname].sap_system_hana_db_sid is defined)
- (sap_hana_install_sid is defined or sap_system_hana_db_sid is defined) or (hostvars[inventory_hostname].vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default(inventory_hostname)].sap_system_hana_db_sid is defined)


- name: Set facts for all hosts - use facts from localhost - SAP SWPM
Expand All @@ -42,7 +55,7 @@
sap_swpm_db_sid: "{{ sap_swpm_db_sid | default(sap_system_hana_db_sid) | default('') }}"
sap_swpm_db_instance_nr: "{{ sap_swpm_db_instance_nr | default(sap_system_hana_db_instance_nr) | default('') }}"
when:
- (sap_swpm_sid is defined or sap_system_sid is defined) or (hostvars[inventory_hostname].vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][inventory_hostname].sap_system_sid is defined)
- (sap_swpm_sid is defined or sap_system_sid is defined) or (hostvars[inventory_hostname].vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default(inventory_hostname)].sap_system_sid is defined)
- (sap_swpm_templates_install_dictionary is defined or sap_system_sid is defined) or hostvars[inventory_hostname].sap_swpm_templates_install_dictionary is defined


Expand Down Expand Up @@ -131,18 +144,6 @@
- sap_vm_provision_iac_platform == "ibmpowervm_vm" or sap_vm_provision_iac_platform == "ibmcloud_powervs"


# Required when defining Ansible Role variables within the host_specifications_dictionary for multiple SAP Systems / SAP Landscapes
- name: Set facts for all hosts - use facts from localhost - SAP Variables from host_specifications_dictionary
ansible.builtin.set_fact:
"{{ host_spec_sap_item }}": "{{ lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary')[sap_vm_provision_host_specification_plan][inventory_hostname][host_spec_sap_item] }}"
loop: "{{ vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][inventory_hostname].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list }}"
loop_control:
loop_var: host_spec_sap_item

- name: Set facts for all hosts - use facts from localhost - Host Specifications Dictionary
ansible.builtin.set_fact:
host_specifications_dictionary: "{{ lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary') }}"

# Set default to none, this will not set the var if the group does not exist
- name: Set facts for all hosts - sap_vm_provision_dynamic_inventory_* hostname variables to identify hosts for other Ansible Roles
ansible.builtin.set_fact:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
host_node_scaleout_origin_spec: "{{ ansible_hostname | regex_replace('^(.+?)\\d*$', '\\1') }}"
when:
- sap_vm_provision_calculate_sap_hana_scaleout_active_coordinator is defined
- not inventory_hostname in vars[ansible_prompt_iac_platform_choice + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan].keys()
- not inventory_hostname in lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary')[sap_vm_provision_host_specification_plan]

# Use inventory_hostname_short to retrieve host specification from the dictionary. While ansible_hostname will work for Ansible only, using Ansible>Terraform may see ansible_hostname as 'localhost' and fail
# For end user ease of use, the host specifications dictionary uses disk_count to indicate how many disks will be provisioned
Expand Down
4 changes: 2 additions & 2 deletions roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
# - "{{ sap_vm_provision_dynamic_inventory_nw_pas_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_pas_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_pas_hostname }}"
# Allows to build ASCS ERS cluster without PAS if PAS details are not provided
- "{{ sap_vm_provision_dynamic_inventory_nw_pas_ip | string + '\t' + sap_vm_provision_dynamic_inventory_nw_pas_hostname + '.' + ansible_domain + '\t' + sap_vm_provision_dynamic_inventory_nw_pas_hostname
if (sap_vm_provision_dynamic_inventory_nw_pas_hostname is defined and sap_vm_provision_dynamic_inventory_nw_pas_hostname | length > 0 )
and (sap_vm_provision_dynamic_inventory_nw_pas_ip is defined and sap_vm_provision_dynamic_inventory_nw_pas_ip | length > 0) else ''}}"
if (sap_vm_provision_dynamic_inventory_nw_pas_hostname is defined and sap_vm_provision_dynamic_inventory_nw_pas_hostname | length > 0 )
and (sap_vm_provision_dynamic_inventory_nw_pas_ip is defined and sap_vm_provision_dynamic_inventory_nw_pas_ip | length > 0) else ''}}"
when:
- (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0))
- item != ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

- name: Set fact to hold all inventory hosts in all groups
ansible.builtin.set_fact:
groups_merged_list: "{{ [ [ groups['hana_primary'] | default([]) ] , [ groups['hana_secondary'] | default([]) ] , [ groups['nwas_ascs'] | default([]) ] , [ groups['nwas_ers'] | default([]) ] , [ groups['nwas_pas'] | default([]) ] , [ groups['nwas_aas'] | default([]) ] ] | flatten | select() }}"
groups_merged_list: "{{ [ [ groups['hana_primary'] | default([]) ] , [ groups['hana_secondary'] | default([]) ] , [ groups['anydb_primary'] | default([]) ] , [ groups['anydb_secondary'] | default([]) ] , [ groups['nwas_ascs'] | default([]) ] , [ groups['nwas_ers'] | default([]) ] , [ groups['nwas_pas'] | default([]) ] , [ groups['nwas_aas'] | default([]) ] ] | flatten | select() }}"

- name: Set Ansible Vars
register: __sap_vm_provision_task_ansible_vars_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

- name: Set fact to hold all inventory hosts in all groups
ansible.builtin.set_fact:
groups_merged_list: "{{ [ [ groups['hana_primary'] | default([]) ] , [ groups['hana_secondary'] | default([]) ] , [ groups['nwas_ascs'] | default([]) ] , [ groups['nwas_ers'] | default([]) ] , [ groups['nwas_pas'] | default([]) ] , [ groups['nwas_aas'] | default([]) ] ] | flatten | select() }}"
groups_merged_list: "{{ [ [ groups['hana_primary'] | default([]) ] , [ groups['hana_secondary'] | default([]) ] , [ groups['anydb_primary'] | default([]) ] , [ groups['anydb_secondary'] | default([]) ] , [ groups['nwas_ascs'] | default([]) ] , [ groups['nwas_ers'] | default([]) ] , [ groups['nwas_pas'] | default([]) ] , [ groups['nwas_aas'] | default([]) ] ] | flatten | select() }}"

- name: Set Ansible Vars
register: __sap_vm_provision_task_ansible_vars_set
Expand Down
Loading

0 comments on commit d4486a1

Please sign in to comment.