salt icon indicating copy to clipboard operation
salt copied to clipboard

hostname inconsistency between states.network and modules.network

Open Lomexian opened this issue 10 years ago • 7 comments

Description of Issue/Question

Inconsistency when using states.network vs modules.network on a systemd distro, modules.network appears to work correctly.

Setup

tested on Centos 7

State Module:

System:
  network.system:
    - hostname: test.local

vs Execution Module:

salt 'host' network.mod_hostname test.local

Steps to Reproduce Issue

State file will change the /etc/sysconfig/network file

execution module will use hostnamectl

Versions Report

Salt Version:
           Salt: 2016.3.1

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 7.2.1511 Core
        machine: x86_64
        release: 3.10.0-327.el7.x86_64
         system: Linux
        version: CentOS Linux 7.2.1511 Core

Lomexian avatar Nov 17 '16 14:11 Lomexian

@Lomexian thanks it looks like the state module is calling ip.get_network_settings with the kwargs presented, instead of calling network.mod_hostname. To be clear what are you proposing? Do you want network.settings to have same behavior as network.mod_hostname or the other way around?

Ch3LL avatar Nov 17 '16 20:11 Ch3LL

Sorry didn't explain terribly well. On a systemd server it appears /etc/sysconfig/network is no longer used for setting hostname. Therefore I propose that the state module check for the presence of systemd then update the hostname via hostnamectl rather than continue to modify the /etc/sysconfig/network file which no longer provides that functionality.

Lomexian avatar Nov 18 '16 09:11 Lomexian

ahhh gotchya. Yeah I think this is a sound approach. Will label as bug. Thanks for clarifying :)

Ch3LL avatar Nov 19 '16 00:11 Ch3LL

Looking into this, network.mod_hostname is called only if apply_hostname is set to True. Verified this on a CentOS 7, hostname is not set via hostnamectl unless apply_hostname is specified.

The documentation isn't very detailed and doesn't call that out specifically, even giving an example with hostname but not including apply_hostname.

I'm not sure if the best approach to this would be describing this as expected behavior in the documentation, or just remove requiring apply_hostname as a parameter to set the hostname with this method.

dankolbrs avatar Mar 06 '17 23:03 dankolbrs

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Sep 14 '18 23:09 stale[bot]

Tested on CentOS 7.5 : network.mod_hostname sillyserver , the server name is now 'sillyserver' (OK) but then the line "search mydomain.com" in /etc/resolv.conf file disappears ! I face same issues on some salt-cloud -p ... command when deploying ( at hostname set step?...) Without the "search...." line in resolv.conf, the server do not access the salt-master anymore... => switch to hostnamectl should be done for CentOS 7 and Red Hat 7 Doing directly hostnamectl set-hosname command, the /etc/resolv.conf file is not modified (as expected)

thefirstzven avatar Nov 09 '18 14:11 thefirstzven

@thefirstzven can you please open a new issue with all the details since this is closed.

Ch3LL avatar Nov 09 '18 15:11 Ch3LL