Skip to content

Commit

Permalink
sap_vm_provision: nolog test fix batch 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-freeman committed Apr 29, 2024
1 parent 294427e commit 51ac613
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Therefore use without any parameter to retrieve list of all SSH Public Keys and filter in Ansible
- name: Get all SSH Public Keys in MS Azure
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_key_pair_name_ssh_host_public_keys
register: __sap_vm_provision_task_msazure_key_pair_name_ssh_host_public_keys
azure.azcollection.azure_rm_sshpublickey_info:
# Azure credentials
subscription_id: "{{ sap_vm_provision_msazure_subscription_id }}"
Expand All @@ -31,11 +31,11 @@

- name: Set fact for selected SSH Public Key in MS Azure
ansible.builtin.set_fact:
__sap_vm_provision_msazure_key_pair_name_ssh_host_public_key_value: "{{ (__sap_vm_provision_msazure_key_pair_name_ssh_host_public_keys.ssh_keys | selectattr('name', '==', sap_vm_provision_msazure_key_pair_name_ssh_host_public_key))[0].public_key }}"
__sap_vm_provision_task_msazure_key_pair_name_ssh_host_public_key_value: "{{ (__sap_vm_provision_task_msazure_key_pair_name_ssh_host_public_keys.ssh_keys | selectattr('name', '==', sap_vm_provision_msazure_key_pair_name_ssh_host_public_key))[0].public_key }}"

- name: Get Private DNS Zone Virtual Network Links
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_private_dns_virtual_network_links
register: __sap_vm_provision_task_msazure_private_dns_virtual_network_links
azure.azcollection.azure_rm_privatednszonelink_info:
# DNS may exist in separate Resource Group. Use empty string var (or default false if undefined) to evaluate to false boolean, and use Python or logic operator
resource_group: "{{ (sap_vm_provision_msazure_private_dns_resource_group_name | default(false)) or sap_vm_provision_msazure_resource_group_name }}"
Expand All @@ -48,7 +48,7 @@

- name: Set boolean fact for Auto Registration of DNS Records from Private DNS Zone Virtual Network Link
ansible.builtin.set_fact:
__sap_vm_provision_msazure_private_dns_auto_register_records: "{{ (__sap_vm_provision_msazure_private_dns_virtual_network_links.virtualnetworklinks | selectattr('virtual_network.id', 'search', sap_vm_provision_msazure_vnet_name))[0].registration_enabled }}"
__sap_vm_provision_task_msazure_private_dns_auto_register_records: "{{ (__sap_vm_provision_task_msazure_private_dns_virtual_network_links.virtualnetworklinks | selectattr('virtual_network.id', 'search', sap_vm_provision_msazure_vnet_name))[0].registration_enabled }}"

- name: Provision hosts to MS Azure
register: __sap_vm_provision_task_provision_host_all_run
Expand Down Expand Up @@ -105,7 +105,7 @@
tenant: "{{ sap_vm_provision_msazure_tenant_id }}"
client_id: "{{ sap_vm_provision_msazure_app_client_id }}"
secret: "{{ sap_vm_provision_msazure_app_client_secret }}"
when: not __sap_vm_provision_msazure_private_dns_auto_register_records
when: not __sap_vm_provision_task_msazure_private_dns_auto_register_records

# - ansible.builtin.debug:
# var: __sap_vm_provision_task_provision_host_all_add.results
Expand All @@ -118,8 +118,8 @@
ansible.builtin.fail:
msg: "{{ lookup('ansible.builtin.vars', loop_item) }}"
loop:
- __sap_vm_provision_msazure_key_pair_name_ssh_host_public_keys
- __sap_vm_provision_msazure_private_dns_virtual_network_links
- __sap_vm_provision_task_msazure_key_pair_name_ssh_host_public_keys
- __sap_vm_provision_task_msazure_private_dns_virtual_network_links
- __sap_vm_provision_task_provision_host_all_run
- __sap_vm_provision_task_provision_host_single_vnic_info
- __sap_vm_provision_task_provision_host_single_vnic
Expand Down Expand Up @@ -250,18 +250,18 @@
ansible.builtin.fail:
msg: "{{ lookup('ansible.builtin.vars', loop_item) }}"
loop:
- __sap_vm_provision_msazure_vnet_subnet_rt_info
- __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_hana
- __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_ascs
- __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_ers
- __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_pas
- __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_aas
- __sap_vm_provision_msazure_iam_role_fencing
- __sap_vm_provision_msazure_vm_info_collect
- __sap_vm_provision_msazure_vnet_subnet_info
- __sap_vm_provision_msazure_lb1a_info
- __sap_vm_provision_msazure_lb1b_info
- __sap_vm_provision_msazure_lb2_info
- __sap_vm_provision_task_msazure_vnet_subnet_rt_info
- __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_hana
- __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_ascs
- __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_ers
- __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_pas
- __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_aas
- __sap_vm_provision_task_msazure_iam_role_fencing
- __sap_vm_provision_task_msazure_vm_info_collect
- __sap_vm_provision_task_msazure_vnet_subnet_info
- __sap_vm_provision_task_msazure_lb1a_info
- __sap_vm_provision_task_msazure_lb1b_info
- __sap_vm_provision_task_msazure_lb2_info
- __sap_vm_provision_task_provision_host_single_vnic1
- __sap_vm_provision_task_provision_host_single_vnic2
loop_control:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
ssh_password_enabled: false
ssh_public_keys:
- path: /home/azureadmin/.ssh/authorized_keys
key_data: "{{ __sap_vm_provision_msazure_key_pair_name_ssh_host_public_key_value }}"
key_data: "{{ __sap_vm_provision_task_msazure_key_pair_name_ssh_host_public_key_value }}"
vm_size: "{{ 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)].virtual_machine_profile }}"
image:
publisher: "{{ lookup('ansible.builtin.vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_os_image_dictionary')[sap_vm_provision_msazure_vm_host_os_image].publisher }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

# - name: Gather information about MS Azure Route Table for the VNet Subnet
# register: __sap_vm_provision_msazure_vnet_subnet_rt_info
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_info
# no_log: "{{ __sap_vm_provision_no_log }}"
# azure.azcollection.azure_rm_routetable_info:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
Expand All @@ -14,10 +14,10 @@

# - name: Ansible MS Azure Route Table append route for SAP HANA HA
# no_log: "{{ __sap_vm_provision_no_log }}"
# register: __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_hana
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_hana
# azure.azcollection.azure_rm_route:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
# route_table_name: "{{ __sap_vm_provision_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# route_table_name: "{{ __sap_vm_provision_task_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# name: "{{ sap_swpm_db_host }}-rt"
# address_prefix: "{{ sap_ha_pacemaker_cluster_vip_hana_primary_ip_address | default('192.168.1.90/32') }}"
# next_hop_type: "virtual_appliance"
Expand Down Expand Up @@ -57,10 +57,10 @@

# - name: Ansible MS Azure Route Table append route for SAP NetWeaver ASCS HA
# no_log: "{{ __sap_vm_provision_no_log }}"
# register: __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_ascs
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_ascs
# azure.azcollection.azure_rm_route:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
# route_table_name: "{{ __sap_vm_provision_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# route_table_name: "{{ __sap_vm_provision_task_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# name: "{{ sap_swpm_ascs_instance_hostname }}-rt"
# address_prefix: "{{ sap_ha_pacemaker_cluster_vip_nwas_abap_ascs_ip_address | default('192.168.2.10/32') }}"
# next_hop_type: "virtual_appliance"
Expand Down Expand Up @@ -100,10 +100,10 @@

# - name: Ansible MS Azure Route Table append route for SAP NetWeaver ERS HA
# no_log: "{{ __sap_vm_provision_no_log }}"
# register: __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_ers
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_ers
# azure.azcollection.azure_rm_route:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
# route_table_name: "{{ __sap_vm_provision_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# route_table_name: "{{ __sap_vm_provision_task_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# name: "{{ sap_swpm_ers_instance_hostname }}-rt"
# address_prefix: "{{ sap_ha_pacemaker_cluster_vip_nwas_abap_ers_ip_address | default('192.168.2.11/32') }}"
# next_hop_type: "virtual_appliance"
Expand Down Expand Up @@ -145,10 +145,10 @@

# - name: Ansible MS Azure Route Table append route for SAP NetWeaver PAS HA
# no_log: "{{ __sap_vm_provision_no_log }}"
# register: __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_pas
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_pas
# azure.azcollection.azure_rm_route:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
# route_table_name: "{{ __sap_vm_provision_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# route_table_name: "{{ __sap_vm_provision_task_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# name: "{{ sap_swpm_pas_instance_hostname }}-rt"
# address_prefix: "{{ sap_ha_pacemaker_cluster_vip_nwas_abap_pas_ip_address | default('192.168.2.12/32') }}"
# next_hop_type: "virtual_appliance"
Expand Down Expand Up @@ -188,10 +188,10 @@

# - name: Ansible MS Azure Route Table append route for SAP NetWeaver AAS HA
# no_log: "{{ __sap_vm_provision_no_log }}"
# register: __sap_vm_provision_msazure_vnet_subnet_rt_route_sap_netweaver_aas
# register: __sap_vm_provision_task_msazure_vnet_subnet_rt_route_sap_netweaver_aas
# azure.azcollection.azure_rm_route:
# resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
# route_table_name: "{{ __sap_vm_provision_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# route_table_name: "{{ __sap_vm_provision_task_msazure_vnet_subnet_rt_info.route_tables[0].id }}"
# name: "{{ sap_swpm_aas_instance_hostname }}-rt"
# address_prefix: "{{ sap_ha_pacemaker_cluster_vip_nwas_abap_aas_ip_address | default('192.168.2.13/32') }}"
# next_hop_type: "virtual_appliance"
Expand Down Expand Up @@ -231,7 +231,7 @@

- name: MS Azure IAM Role - Definition
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_iam_role_fencing
register: __sap_vm_provision_task_msazure_iam_role_fencing
azure.azcollection.azure_rm_roledefinition:
name: "Linux Fence Agent Role"
description: "Allows to power-off and start virtual machines"
Expand All @@ -254,7 +254,7 @@

- name: MS Azure - GenericRestClient call to Virtual Machine API to identify Managed Service Identity (MSI)
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_vm_info_collect
register: __sap_vm_provision_task_msazure_vm_info_collect
azure.azcollection.azure_rm_resource_info:
resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
provider: Compute
Expand All @@ -275,15 +275,15 @@
azure.azcollection.azure_rm_roleassignment:
#auth_source: msi
role_definition_id:
"{{ __sap_vm_provision_msazure_iam_role_fencing.id }}"
"{{ __sap_vm_provision_task_msazure_iam_role_fencing.id }}"
scope: "/subscriptions/{{ sap_vm_provision_msazure_subscription_id }}"
assignee_object_id: "{{ host_node.response[0].identity.principalId | default(none) }}"
# Azure credentials
subscription_id: "{{ sap_vm_provision_msazure_subscription_id }}"
tenant: "{{ sap_vm_provision_msazure_tenant_id }}"
client_id: "{{ sap_vm_provision_msazure_app_client_id }}"
secret: "{{ sap_vm_provision_msazure_app_client_secret }}"
loop: "{{ __sap_vm_provision_msazure_vm_info_collect.results }}"
loop: "{{ __sap_vm_provision_task_msazure_vm_info_collect.results }}"
loop_control:
loop_var: host_node
label: "{{ host_node.response[0].name | default(none) }}" # Use default to avoid "Failed to template 'dict object' has no attribute 'response'"
Expand Down Expand Up @@ -330,7 +330,7 @@

- name: Gather MS Azure Subnet ID
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_vnet_subnet_info
register: __sap_vm_provision_task_msazure_vnet_subnet_info
azure.azcollection.azure_rm_subnet_info:
resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
virtual_network_name: "{{ sap_vm_provision_msazure_vnet_name }}"
Expand All @@ -349,7 +349,7 @@
name: "lb-vip-hana{{ vip_index_nr }}"
private_ip_address: "{{ vip_item | regex_replace('/.*', '') }}"
private_ip_allocation_method: "Static"
subnet: "{{ __sap_vm_provision_msazure_vnet_subnet_info.subnets[0].id }}"
subnet: "{{ __sap_vm_provision_task_msazure_vnet_subnet_info.subnets[0].id }}"
zones: ["1", "2", "3"] # Zone-redundant
when:
- vip_item | length > 0
Expand All @@ -368,7 +368,7 @@
name: "lb-vip-anydb{{ vip_index_nr }}"
private_ip_address: "{{ vip_item | regex_replace('/.*', '') }}"
private_ip_allocation_method: "Static"
subnet: "{{ __sap_vm_provision_msazure_vnet_subnet_info.subnets[0].id }}"
subnet: "{{ __sap_vm_provision_task_msazure_vnet_subnet_info.subnets[0].id }}"
zones: ["1", "2", "3"] # Zone-redundant
when:
- vip_item | length > 0
Expand All @@ -387,7 +387,7 @@
name: "lb-vip-nwas{{ vip_index_nr }}"
private_ip_address: "{{ vip_item | regex_replace('/.*', '') }}"
private_ip_allocation_method: "Static"
subnet: "{{ __sap_vm_provision_msazure_vnet_subnet_info.subnets[0].id }}"
subnet: "{{ __sap_vm_provision_task_msazure_vnet_subnet_info.subnets[0].id }}"
zones: ["1", "2", "3"] # Zone-redundant
when:
- vip_item | length > 0
Expand Down Expand Up @@ -528,7 +528,7 @@

- name: MS Azure Load Balancer (network L4) - Create NLB for SAP HANA with Virtual IP and Health Probe configuration
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_lb1a_info
register: __sap_vm_provision_task_msazure_lb1a_info
azure.azcollection.azure_rm_loadbalancer:
resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
name: "lb-sap-hana-ha" # "lb-sap-ha"
Expand All @@ -547,7 +547,7 @@

- name: MS Azure Load Balancer (network L4) - Create NLB for SAP AnyDB with Virtual IP and Health Probe configuration
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_lb1b_info
register: __sap_vm_provision_task_msazure_lb1b_info
azure.azcollection.azure_rm_loadbalancer:
resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
name: "lb-sap-anydb-ha" # "lb-sap-ha"
Expand All @@ -566,12 +566,12 @@

- name: MS Azure Load Balancer (network L4) - Define Ansible Variable of Load Balancer for Database Server
ansible.builtin.set_fact:
__sap_vm_provision_msazure_lb1_info: "{{ __sap_vm_provision_msazure_lb1a_info if (groups['hana_secondary'] is defined and (groups['hana_secondary']|length>0)) else __sap_vm_provision_msazure_lb1b_info if (groups['anydb_secondary'] is defined and (groups['anydb_secondary']|length>0)) }}"
__sap_vm_provision_task_msazure_lb1_info: "{{ __sap_vm_provision_task_msazure_lb1a_info if (groups['hana_secondary'] is defined and (groups['hana_secondary']|length>0)) else __sap_vm_provision_task_msazure_lb1b_info if (groups['anydb_secondary'] is defined and (groups['anydb_secondary']|length>0)) }}"
when: (groups["hana_secondary"] is defined and (groups["hana_secondary"]|length>0)) or (groups["anydb_secondary"] is defined and (groups["anydb_secondary"]|length>0))

- name: MS Azure Load Balancer (network L4) - Create NLB for SAP NetWeaver with Virtual IP and Health Probe configuration
no_log: "{{ __sap_vm_provision_no_log }}"
register: __sap_vm_provision_msazure_lb2_info
register: __sap_vm_provision_task_msazure_lb2_info
azure.azcollection.azure_rm_loadbalancer:
resource_group: "{{ sap_vm_provision_msazure_resource_group_name }}"
name: "lb-sap-nwas-ha"
Expand All @@ -590,17 +590,17 @@

- name: Set fact to hold loop variables from include_tasks when SAP HANA HA
ansible.builtin.set_fact:
lb_ha_sap_hana: "{{ __sap_vm_provision_msazure_lb1_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-hana') | map(attribute='id') | first }}"
lb_ha_sap_hana: "{{ __sap_vm_provision_task_msazure_lb1_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-hana') | map(attribute='id') | first }}"
when: (groups["hana_secondary"] is defined and (groups["hana_secondary"]|length>0))

- name: Set fact to hold loop variables from include_tasks when SAP AnyDB HA
ansible.builtin.set_fact:
lb_ha_sap_anydb: "{{ __sap_vm_provision_msazure_lb1_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-anydb') | map(attribute='id') | first }}"
lb_ha_sap_anydb: "{{ __sap_vm_provision_task_msazure_lb1_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-anydb') | map(attribute='id') | first }}"
when: (groups["anyb_secondary"] is defined and (groups["anydb_secondary"]|length>0))

- name: Set fact to hold loop variables from include_tasks when SAP NetWeaver HA
ansible.builtin.set_fact:
lb_ha_sap_nwas: "{{ __sap_vm_provision_msazure_lb2_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-nwas-ascs') | map(attribute='id') | first }}"
lb_ha_sap_nwas: "{{ __sap_vm_provision_task_msazure_lb2_info.state.backend_address_pools | selectattr('name', '==', 'lb-backend-pool-nwas-ascs') | map(attribute='id') | first }}"
when: (groups["nwas_ers"] is defined and (groups["nwas_ers"]|length>0))

- name: Update network interfaces for MS Azure VM - for SAP HANA HA with load balancing
Expand Down
Loading

0 comments on commit 51ac613

Please sign in to comment.