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

State fails when network.system's hostname arg has no dots #15085

Closed
thenewwazoo opened this issue Aug 19, 2014 · 9 comments
Closed

State fails when network.system's hostname arg has no dots #15085

thenewwazoo opened this issue Aug 19, 2014 · 9 comments
Labels
Bug broken, incorrect, or confusing behavior Execution-Module Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-low 4th level, cosemtic problems, work around exists
Milestone

Comments

@thenewwazoo
Copy link

State network.system accepts a hostname argument. When that argument has a value that is not a FQDN (i.e. when it has no dots), the state fails.

# hostname.sls
change_hostname:
  network.system:
    - hostname: shortname

results in:

vagrant@minion:~$ sudo salt-call state.sls hostname
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'base', ** done ** 'hostname.sls'
[INFO    ] Running state [change_hostname] at time 19:48:12.219712
[INFO    ] Executing state network.system for change_hostname
[INFO    ] Using existing setting -- Setting: networking Value: no
[INFO    ] Executing command 'runlevel /run/utmp' in directory '/home/vagrant'
[INFO    ] output: N 2
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/salt/state.py", line 1379, in call
    **cdata['kwargs'])
  File "/usr/lib/pymodules/python2.7/salt/states/network.py", line 380, in system
    new = __salt__['ip.build_network_settings'](**kwargs)
  File "/usr/lib/pymodules/python2.7/salt/modules/debian_ip.py", line 1512, in build_network_settings
    domainname = sline[1]
IndexError: list index out of range

[INFO    ] Completed state [change_hostname] at time 19:48:12.239322
local:
----------
          ID: change_hostname
    Function: network.system
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/pymodules/python2.7/salt/state.py", line 1379, in call
                  **cdata['kwargs'])
                File "/usr/lib/pymodules/python2.7/salt/states/network.py", line 380, in system
                  new = __salt__['ip.build_network_settings'](**kwargs)
                File "/usr/lib/pymodules/python2.7/salt/modules/debian_ip.py", line 1512, in build_network_settings
                  domainname = sline[1]
              IndexError: list index out of range
     Changes:

Summary
------------
Succeeded: 0
Failed:    1
------------
Total:     1

This is observed on:

vagrant@minion:~$ salt-minion --version ; lsb_release -a ; uname -a
salt-minion 2014.1.10 (Hydrogen)
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise
Linux minion 3.8.0-44-generic #66~precise1-Ubuntu SMP Tue Jul 15 04:01:04 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
vagrant@minion:~$
@thenewwazoo
Copy link
Author

This is related to, but not the same as #6922

@cachedout
Copy link
Contributor

I can confirm this issue. Good catch. Should be easy enough to fix.

cc: @garethgreenaway

@cachedout cachedout added this to the Approved milestone Aug 19, 2014
@garethgreenaway
Copy link
Contributor

Thought this was already fixed in 2014.7.

@cachedout
Copy link
Contributor

I tested this against 2014.7 and still see errors. Stacktrace below:

[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [change_hostname] at time 15:25:24.881754
[INFO    ] Executing state network.system for change_hostname
[INFO    ] Using existing setting -- Setting: networking Value: no
[INFO    ] Executing command 'runlevel /run/utmp' in directory '/home/mp'
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/home/mp/Devel/salt/salt/state.py", line 1517, in call
    **cdata['kwargs'])
  File "/home/mp/Devel/salt/salt/states/network.py", line 395, in system
    new = __salt__['ip.build_network_settings'](**kwargs)
  File "/home/mp/Devel/salt/salt/modules/debian_ip.py", line 1798, in build_network_settings
    domainname = sline[1]
IndexError: list index out of range

[INFO    ] Completed state [change_hostname] at time 15:25:24.919208
local:
----------
          ID: change_hostname
    Function: network.system
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/home/mp/Devel/salt/salt/state.py", line 1517, in call
                  **cdata['kwargs'])
                File "/home/mp/Devel/salt/salt/states/network.py", line 395, in system
                  new = __salt__['ip.build_network_settings'](**kwargs)
                File "/home/mp/Devel/salt/salt/modules/debian_ip.py", line 1798, in build_network_settings
                  domainname = sline[1]
              IndexError: list index out of range
     Started: 15:25:24.881754
     Duration: 37.454 ms
     Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

@garethgreenaway
Copy link
Contributor

Okay. Will take a look.

@cachedout
Copy link
Contributor

Thanks as always @garethgreenaway. Much appreciated. :]

@thenewwazoo
Copy link
Author

Thanks for the validation, cachedout. I'm currently spinning up a 2014.7 env to see if I can resolve this (and the other issues) quickly.

@garethgreenaway
Copy link
Contributor

I see the issue. Should have a PR in a few minutes.

@basepi
Copy link
Contributor

basepi commented Aug 25, 2014

Looks like @garethgreenaway got this, so I'm going to go ahead and close. Thanks!

@basepi basepi closed this as completed Aug 25, 2014
@jfindlay jfindlay added the Platform Relates to OS, containers, platform-based utilities like FS, system based apps label May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Execution-Module Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

5 participants