lib/sles4sap/sap_deployment_automation_framework/configure_workload_tfvars.pm

SYNOPSIS

Library with common functions for Microsoft SDAF deployment automation that help with preparation of 'WORKLOAD-ZONE' tfvars file. Generated file is following example template: https://github.com/Azure/SAP-automation-samples/blob/main/Terraform/WORKSPACES/SYSTEM/LAB-SECE-SAP04-L00/LAB-SECE-SAP04-L00.tfvars

write_tfvars_file

write_tfvars_file(tfvars_file=>'/path/towards/happiness', tfvars_data=>$tfvars_data);

Data provided in $args{tfvars_data} is compiled into tfvars file format and written into target $args{tfvars_file} file located on deployer VM. $args{tfvars_data} is a HASHREF containing individual sections that should be included in final tfvars content. file_header is placed as a comment as a first line of the defined section.

Example: { file_header => "Comment placed on top of the tfvars file", env_definitions => {header => 'Comment placed on top of a section - env_definitions', tfvars_variable_1 = '"value_1"', tfvars_variable_2 = '"value2"'}, workload_networking => {header => 'Comment placed on top of a section - workload_networking', tfvars_variable_boolean = 'true', tfvars_variable_integer = '4'}, }

Results in: Pay attention to double quotes. Only strings are double quoted. Bool and int are not. ### Comment placed on top of the tfvars file

### Comment placed on top of a section - env_definitions tfvars_variable_1 = "value_1" tfvars_variable_2 = "value_2"

### Comment placed on top of a section - env_definitions tfvars_variable_boolean = true tfvars_variable_integer = 4

compile_tfvars_section

compile_tfvars_section($section_data);

Converts HASHREF based tfvars section into terraform format and returns it as a string. Results in: # Header variable_1 = 'value_1' variable_2 = 'value_2'

create_workload_tfvars

create_workload_tfvars(network_data=>[subnet_a => '192.168.1.0/26', subnet_b => '192.168.1.65/26'],
workload_vnet_code=>'FUN' [, environment=>'LAB', location=>'swedencentral', resource_group=>'Funky', job_id=>'1']);

Function that generates workload zone tfvars content according to arguments and OpenQA variables provided. Content is generated in perl and transformed into tfvars format. File is uploaded into OpenQA format.

define_workload_environment

define_workload_environment(environment=>'LAB', location=>'swedencentral', resource_group=>'OpenQA');

Returns tfvars environment definitions section in HASHREF format. This section includes various environmental parameters and parameters that do not belong to a specific section. Example: {environment : 'LAB', location : 'swedencentral' ... }

define_networking

define_networking(workload_vnet_code=>'OpenQA-42', job_id=>'42');

Returns tfvars networking parameter section in HASHREF format. Example: {network_logical_name : 'VNET01', network_name : 'OpenQA-VNET01' ... }

define_nat_section

define_nat_section(environment=>'LAB', sdaf_region=>'swedencentral', workload_vnet_code=>'OpenQA-42');

Returns tfvars section related to NAT setup in HASHREF format. Example: {nat_gateway_name : 'NAT-01', network_name : 'OpenQA-NAT01' ... }

define_subnets

define_subnets(network_data=>$network_data);

Returns tfvars section related to subnet setup in HASHREF format. Example: {network_address_space : '192.168.1.0/26', db_subnet_address_prefix : '192.168.1.0/28' ... }

define_iscsi_devices

define_iscsi_devices();

Returns tfvars section related to setup of iSCSI server(s) in HASHREF format. iSCSI is used mostly for SBD based fencing. Example: {iscsi_count : '3', iscsi_useDHCP : 'true' ... }

define_storage_account

define_storage_account();

Returns tfvars section related to storage account settings in HASHREF format. Storage accounts related to installation media and SAP transport shares. Example: {install_volume_size : '1024', NFS_provider : 'AFS' ... }