mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06: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:
parent
a11cddd75b
commit
e4259d5b49
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user