Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
hosts not replacing existing entry #49392
Description of Issue/Question
When using host.present, if changing the IP address, a second entry is created and the old one is not removed.
Actually, it could be achieved with:
# remove previous ip previous_backend_ip: host.only: - hostnames:  # add new ip backend: host.present: - ip: backend_ip
But i don't really find it satisfying. I would assume that changing the ip using
Would you accept a MR to change
just my 2 cents: I completely agree with @mattLLVW that the current behaviour is completely useless (because the new entry will never be used) and counter-intuitive (because you think salt manages /etc/hosts, which it does but in a non-functional way)
I hope someone from team-core can react on this issue so that work can be done to solve it.
referenced this issue
Nov 27, 2018
The current behavior is correct for the name of the state, in my opinion. The name of the state implies that entries are in the hosts file for the specified host and IP address(es), it does not imply that those are the only entries in the hosts file. That said, there is certainly a use-case for removing any entries with IPs not defined in the state. I've added this via a new
See #50657 for details.