rhel-system-roles-sap/SOURCES/sap-preconfigure-6169bd8d44...

50 lines
2.3 KiB
Diff

commit 6169bd8d447ce60012f7fd8a3d664a1bae2b3c0a
Author: Bernd Finger <bfinger@redhat.com>
Date: Tue Feb 23 18:56:13 2021 +0100
fix issue #125
diff --git a/tasks/RedHat/generic/assert-etc-hosts.yml b/tasks/RedHat/generic/assert-etc-hosts.yml
index 3304d73..b8d8830 100644
--- a/tasks/RedHat/generic/assert-etc-hosts.yml
+++ b/tasks/RedHat/generic/assert-etc-hosts.yml
@@ -54,8 +54,10 @@
success_msg: "PASS: There is only one line containing '{{ sap_ip }}' in /etc/hosts."
ignore_errors: "{{ sap_preconfigure_assert_ignore_errors|d(false) }}"
-- name: Check for duplicate entries of {{ sap_hostname }}.{{ sap_domain }} in /etc/hosts
- command: awk 'BEGIN{a=0}/{{ sap_hostname }}.{{ sap_domain }}/{a++}END{print a}' /etc/hosts
+- name: Check for duplicate or missing entries of {{ sap_hostname }}.{{ sap_domain }} in /etc/hosts
+ command: awk '/^{{ sap_hostname }}.{{ sap_domain }} /||
+ / {{ sap_hostname }}.{{ sap_domain }} /||
+ / {{ sap_hostname }}.{{ sap_domain }}$/{a++}END{print a}' /etc/hosts
register: __shell_03_result
ignore_errors: yes
changed_when: no
@@ -67,8 +69,10 @@
success_msg: "PASS: There is only one line containing '{{ sap_hostname }}.{{ sap_domain }}' in /etc/hosts."
ignore_errors: "{{ sap_preconfigure_assert_ignore_errors|d(false) }}"
-- name: Check for duplicate entries of {{ sap_hostname }} in /etc/hosts
- command: awk 'BEGIN{a=0}/{{ sap_hostname }}/{a++}END{print a}' /etc/hosts
+- name: Check for duplicate or missing entries of {{ sap_hostname }} in /etc/hosts
+ command: awk '/^{{ sap_hostname }} /||
+ / {{ sap_hostname }} /||
+ / {{ sap_hostname }}$/{a++}END{print a}' /etc/hosts
register: __shell_04_result
ignore_errors: yes
changed_when: no
diff --git a/tasks/RedHat/generic/configure-etc-hosts.yml b/tasks/RedHat/generic/configure-etc-hosts.yml
index 2ae3a18..0a1ec59 100644
--- a/tasks/RedHat/generic/configure-etc-hosts.yml
+++ b/tasks/RedHat/generic/configure-etc-hosts.yml
@@ -97,7 +97,7 @@
- name: Check for duplicate or missing entries of hostname and fqdn in /etc/hosts
shell: |
- n=$(grep -w "{{ line_item }}" /etc/hosts | wc -l)
+ n=$(awk '/^{{ line_item }} /||/ {{ line_item }} /||/ {{ line_item }}$/{a++}END{print a}' /etc/hosts)
if [ $n -eq 1 ]; then
exit 0
else