mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #11761 from sctsang/develop
fix issue 11760, host entries append to eol, even lines with comments
This commit is contained in:
commit
a52969134c
@ -208,7 +208,14 @@ def add_host(ip, alias):
|
||||
return True
|
||||
|
||||
hosts = _list_hosts()
|
||||
hosts.setdefault(ip, []).append(alias)
|
||||
inserted = False
|
||||
for i, h in hosts.items():
|
||||
for j in range(len(h)):
|
||||
if h[j].startswith('#') and i == ip:
|
||||
h.insert(j, alias)
|
||||
inserted = True
|
||||
if not inserted:
|
||||
hosts.setdefault(ip, []).append(alias)
|
||||
_write_hosts(hosts)
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user