Skip to content

state network.system setting hostname is not idempotent on Debian #32983

Closed

Description

@ssplatt

Description of Issue/Question

configuring a state to manage the hostname using network.system on Debian is not idempotent

Setup

networking_system_config:
  network.system:
    - enabled: true
    - hostname: testing.local
    - apply_hostname: true
    - require_reboot: true

every run:

       ----------
          ID: networking_system_config
           Function: network.system
             Result: True
            Comment: Global network settings are up to date.
            Started: 14:41:50.802055
           Duration: 25.588 ms
            Changes:
              ----------
              network_settings:
                  ---
                  +++
                  @@ -1,3 +1,3 @@
                   NETWORKING=yes
                  -HOSTNAME=testing.local
                  +HOSTNAME=testing
                   DOMAIN=local

separate issues but related:

  • require_reboot: true seems to have no effect, I believe there is an open ticket for that.
  • /etc/hosts doesn't get updated with the new hostname pointing to 127.0.0.1 or 127.0.1.1.

Steps to Reproduce Issue

kitchen converge

Versions Report

root@testing:~# salt-call --local --versions-report
Salt Version:
Salt: 2015.8.8.2

Dependency Versions:
Jinja2: 2.7.3
M2Crypto: Not Installed
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 14.4.0
Python: 2.7.9 (default, Mar 1 2015, 12:57:24)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: 0.8.6
cherrypy: Not Installed
dateutil: 2.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libgit2: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: 1.2.3
pycparser: 2.10
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed

System Versions:
dist: debian 8.3
machine: x86_64
release: 3.16.0-4-amd64
system: debian 8.3

Activity

  1. added
    bug
    severity-medium
    P3
    Platform
    on May 2, 2016
  2. added this to the Approved milestone on May 2, 2016
  3. jfindlay commented on May 2, 2016

    @jfindlay
    Contributor

    @ssplatt, thanks for reporting.

  4. eliasp commented on Oct 19, 2017

    @eliasp
    Contributor

    How to reproduce this AKA what happens a few layers deeper down in the network code:

    1. Apply the network configuration:
    $ salt-call ip.apply_network_settings enabled=True hostname=somehost.domain.tld require_reboot=True apply_hostname=True
    
    1. Get the current network configuration:
    $ salt-call ip.get_network_settings
        - NETWORKING=yes
        - HOSTNAME=somehost.domain.tld
        - DOMAIN=domain.tld
    
    1. Build a new network configuration:
    $ salt-call ip.build_network_settings enabled=True hostname=somehost.domain.tld require_reboot=True apply_hostname=True
        - NETWORKING=yes
        - HOSTNAME=somehost
        - DOMAIN=domain.tld
    
    1. Compare the results of 2 and 3
    • ip.get_network_settings: HOSTNAME=somehost.domain.tld
    • ip.build_network_settings: HOSTNAME=somehost

    Without any warranty for not breaking something else, this simple change fixed that for me:

    diff --git a/salt/modules/debian_ip.py b/salt/modules/debian_ip.py
    index 28f7e6e2c6..4c07ce7eaf 100644
    --- a/salt/modules/debian_ip.py
    +++ b/salt/modules/debian_ip.py
    @@ -2029,7 +2029,6 @@ def build_network_settings(**settings):
     
         # Get hostname and domain from opts
         sline = opts['hostname'].split('.', 1)
    -    opts['hostname'] = sline[0]
         current_domainname = current_network_settings['domainname']
         current_searchdomain = current_network_settings['searchdomain']

    ip.build_network_settings reports now the full FQDN instead of the truncated hostname.

  5. eliasp commented on Sep 26, 2018

    @eliasp
    Contributor

    Still applies to 2018.3.2 on Ubuntu 18.04

  6. stale commented on Jan 9, 2020

    @stale

    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.

  7. CodingMinds commented on Dec 1, 2022

    @CodingMinds

    Still applies to salt-ssh 3005 on macOS 12.6 via brew.
    Managed host is a Ubuntu 20.04.5 LTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3PlatformState-Modulebugseverity-mediumstale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions