Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosts not replacing existing entry #49392

Closed
Poil opened this issue Aug 29, 2018 · 8 comments

Comments

Projects
None yet
7 participants
@Poil
Copy link

commented Aug 29, 2018

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.
In /etc/hosts only the first entry is taken into account, so the change is not taken into account.

Setup

backend:
  host.present:
    - ip: {{ backend_ip }}

Versions Report

# salt --versions-report
Salt Version:
           Salt: 2018.3.2
 
Dependency Versions:
           cffi: 1.11.5
       cherrypy: unknown
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: 0.26.5
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.18
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.26.4
         Python: 3.4.8 (default, Jul 25 2018, 22:08:49)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.2
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.5.1804 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.11.6.el7.x86_64
         system: Linux
        version: CentOS Linux 7.5.1804 Core
@Ch3LL

This comment has been minimized.

Copy link
Contributor

commented Aug 31, 2018

looks like i'm able to replicate this. will need to fix this up.

@Ch3LL Ch3LL added this to the Approved milestone Aug 31, 2018

@mattLLVW

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2018

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 host.present would actually change the ip, not add another entry.
Adding another entry is useless since only the first one is taken into account.

Would you accept a MR to change host.present to have this behavior?

@Ch3LL

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2018

yep :) i think this is the behavior we would want unless someone on @saltstack/team-core disagrees

@daks

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2018

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.

@terminalmage

This comment has been minimized.

Copy link
Contributor

commented 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 remove argument to the state. This functionality should be available in the 2018.3.4 release.

See #50657 for details.

@terminalmage

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

NOTE: The argument is being renamed from remove to clean for consistency with other states in Salt.

@sathieu

This comment has been minimized.

Copy link
Contributor

commented Dec 9, 2018

Should be closed by #50657...

@garethgreenaway

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

Closing this out, if the problem persists please comment & we'll re-open the issue or feel free to open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.