-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sap_swpm: Add support for HA virtual hostname resolution
Signed-off-by: Bernd Finger <[email protected]>
- Loading branch information
1 parent
c12fa43
commit 54c4ed7
Showing
4 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
roles/sap_swpm/tasks/pre_install/assert_hostname_resolution_for_ha.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--- | ||
|
||
# Assert HA settings | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Ensure the dig command is present | ||
ansible.builtin.package: | ||
name: bind-utils | ||
state: present | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Try to resolve sap_swpm_virtual_hostname from DNS | ||
ansible.builtin.command: dig +short +tries=1 +time=1 "{{ sap_swpm_virtual_hostname }}" | ||
register: __sap_swpm_register_virtual_ip_dns | ||
changed_when: false | ||
failed_when: false | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Assign sap_swpm_virtual_ip from DNS | ||
ansible.builtin.set_fact: | ||
__sap_swpm_fact_virtual_ip: "{{ __sap_swpm_register_virtual_ip_dns.stdout_lines[-1] }}" | ||
when: __sap_swpm_register_virtual_ip_dns.stdout_lines | length > 0 | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Try using /etc/hosts for name resolution | ||
when: __sap_swpm_register_virtual_ip_dns.stdout_lines | length == 0 | ||
block: | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Try to resolve sap_swpm_virtual_hostname from /etc/hosts | ||
ansible.builtin.shell: | | ||
awk '/\s{{ sap_swpm_virtual_hostname }}\./||/\s{{ sap_swpm_virtual_hostname }}/{print $1}' /etc/hosts | ||
register: __sap_swpm_register_virtual_ip_etc_hosts | ||
changed_when: false | ||
failed_when: false | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Assign sap_swpm_virtual_ip from /etc/hosts | ||
ansible.builtin.set_fact: | ||
__sap_swpm_fact_virtual_ip: "{{ __sap_swpm_register_virtual_ip_etc_hosts.stdout_lines[-1] }}" | ||
when: __sap_swpm_register_virtual_ip_etc_hosts.stdout_lines | length > 0 | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Assert that sap_swpm_virtual_hostname can be resolved | ||
ansible.builtin.assert: | ||
that: __sap_swpm_fact_virtual_ip | length > 0 | ||
fail_msg: "FAIL: sap_swpm_virtual_hostname cannot be resolved!" | ||
success_msg: "PASS: sap_swpm__virtual_hostname can be resolved." | ||
|
||
- name: SAP SWPM Pre Install - HA settings - Assert that sap_swpm_fact_virtual_ip is part of ansible_all_ipv4_addresses | ||
ansible.builtin.assert: | ||
that: __sap_swpm_fact_virtual_ip in ansible_all_ipv4_addresses | ||
fail_msg: "FAIL: __sap_swpm_fact_virtual_ip is not part of ansible_all_ipv4_addresses!" | ||
success_msg: "PASS: __sap_swpm_fact_virtual_ip is part of ansible_all_ipv4_addresses." |