__hosts: modification results in duplicate lines #40
Labels
No Label
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ungleich-public/cdist#40
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changing
to
results two lines in
/etc/hosts
:I couldn't find a way to work around this.
It seems like a limitation of
__line
to me.Any ideas how this could be addressed?
mentioned in issue #842
@poljakowski:
/etc/hosts
is not that simple…The hostname cannot be considered unique. The default
/etc/hosts
in most distros will likely include something like this:Hostname + IP could maybe be considered unique.
There is also a difference between aliases and multiple entries.
This can be seen when checking out the
gethostby*(3)
functions, which return astruct hostent
(which contains the hostname and aliases.)Given these lines in
/etc/hosts
:the difference can be seen with
getent(1)
:Edit: Another interesting thing about
/etc/hosts
can be observed if sayexample.com
resolves tofc00::1234
using DNS:changed title from __hosts: {---alias -}modification results in duplicate lines to __hosts: modification results in duplicate lines
@ssrq Also take a look at the following discussion: https://code.ungleich.ch/ungleich-public/cdist/-/merge_requests/465.
I think that Dmitry purposely didn't support alias, multiple names are managed by multiple type executions resulting in consistent hosts file.
@ssrq Is the above change: first I used hosts type without alias, run cdist config; then I changed usage of hosts type so that I added alias and run cdist config?
If yes, then this cannot be done with this type which uses line type.
You would have to use first hosts usage with absent then the second usage to add new line.
Or reimplement type/replace usage of line type with logic that detects such cases and appends new alias to the same hosts line.