mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-24 14:17:41 -05:00
CI: fix function that prepare the hosts file before CI run
Without this fix function removed 2 lines from hosts file. Reviewed-By: Oleg Fayans <ofayans@redhat.com>
This commit is contained in:
1 parent
a11cddd75b
commit
e4259d5b49
1 file changed
+4
-2
@@ -115,12 +115,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)
|
||||
|
||||
Reference in new issue
Block a user