Without this fix, function removes more entries from /etc/host than is
required, and it causes installation failure in tests without DNS
Patch attached.
From 13d9bb9fb08f88d61185b89a837b7f75445bd2aa Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Sun, 6 Dec 2015 18:44:43 +0100
Subject: [PATCH] CI: fix function that prepare the hosts file before CI run
Without this fix function removed 2 lines from hosts file.
---
ipatests/test_integration/tasks.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index a295d522d69c28da3c58156c8850e68b83342c53..e75fe505f5ad9b5ffe680f7e37dec6873616ca05 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -114,12 +114,14 @@ def fix_etc_hosts(host):
backup_file(host, paths.HOSTS)
contents = host.get_file_contents(paths.HOSTS)
# Remove existing mentions of the host's FQDN, short name, and IP
+ # Removing of IP must be done as first, otherwise hosts file may be
+ # corrupted
+ contents = re.sub('^%s.*' % re.escape(host.ip), '', contents,
+ flags=re.MULTILINE)
contents = re.sub('\s%s(\s|$)' % re.escape(host.hostname), ' ', contents,
flags=re.MULTILINE)
contents = re.sub('\s%s(\s|$)' % re.escape(host.shortname), ' ', contents,
flags=re.MULTILINE)
- contents = re.sub('^%s.*' % re.escape(host.ip), '', contents,
- flags=re.MULTILINE)
# Add the host's info again
contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
log.debug('Writing the following to /etc/hosts:\n%s', contents)
--
2.5.0
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code