salt icon indicating copy to clipboard operation
salt copied to clipboard

State network.managed fails on Debian (Jessie)

Open multani opened this issue 11 years ago • 4 comments

The following state:

eth0:
  network.managed:
    - enabled: true
    - type: eth
    - ipaddr: 1.2.3.4

produces a /etc/network/interfaces file on Debian with the following content:

auto eth0
    address 1.2.3.4

But it is then unable to parse it back (I just tried to reapply the exact same state just after the first run):

          ID: eth0
    Function: network.managed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1563, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/states/network.py", line 235, in managed
                  old = __salt__['ip.get_interface'](name)
                File "/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py", line 1652, in get_interface
                  adapters = _parse_interfaces()
                File "/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py", line 585, in _parse_interfaces
                  attr, valuestr, addrfam)
              UnboundLocalError: local variable 'addrfam' referenced before assignment
     Started: 10:40:19.277447
    Duration: 0.968 ms
     Changes: 

After "fixing" this bug, there is also a (at least one) subsequent failure dues to undefined variable such as iface_dict from the following line.

$ salt-call --versions-report
                  Salt: 2015.5.0
                Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
                Jinja2: 2.7.3
              M2Crypto: 0.21.1
        msgpack-python: 0.4.2
          msgpack-pure: Not Installed
              pycrypto: 2.6.1
               libnacl: Not Installed
                PyYAML: 3.11
                 ioflo: Not Installed
                 PyZMQ: 14.4.0
                  RAET: Not Installed
                   ZMQ: 4.0.5
                  Mako: Not Installed
 Debian source package: 2015.5.0+ds-1~bpo8+

I may have a look at this one.

multani avatar Jun 09 '15 08:06 multani

@multani, you are welcome to submit pull requests fixing this to the 2015.5 branch. Just be sure to reference this issue when doing so, thanks.

jfindlay avatar Jun 10 '15 21:06 jfindlay

+1

warrenhouzz avatar Jun 13 '15 01:06 warrenhouzz

It's failing to build a correct interfaces file because the state file is missing the proto argument. The template looks for that when building that part of the file. We should add a check to ensure that argument is included before proceeding or have it default to a static interface.

garethgreenaway avatar Jun 29 '15 20:06 garethgreenaway

This is fixed on 2015.5.5, so I am going to close this. If this is still a problem on 2015.5.5 and newer releases, let us know and we can readdress. Thanks everyone!

rallytime avatar Sep 09 '15 20:09 rallytime