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