salt icon indicating copy to clipboard operation
salt copied to clipboard

iptables.delete success format typo

Open ghost opened this issue 12 years ago • 2 comments

Version

           Salt: 2014.1.0
         Python: 2.7.3 (default, Feb 27 2014, 19:58:35)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.10
   msgpack-pure: Not Installed
       pycrypto: 2.4.1
         PyYAML: 3.10
          PyZMQ: 13.0.0
            ZMQ: 3.2.2

The following state triggers the bug:

firewall-disable-updates-80:
    iptables.delete:
        - table: filter
        - chain: OUTPUT
        - jump: ACCEPT
        - match: state
        - connstate: NEW
        - save: True
        - proto: tcp
        - dport: 80
        - order: last

Error generated:

ID: firewall-disable-updates-443
    Function: iptables.delete
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/pymodules/python2.7/salt/state.py", line 1371, in call
                  **cdata['kwargs'])
                File "/usr/lib/pymodules/python2.7/salt/states/iptables.py", line 407, in delete
                  '{2}'.format(name, command.strip()), family)
              IndexError: tuple index out of range

Fix: Line 407 of current release (Ubuntu deb package) reads:

'{2}'.format(name, command.strip()), family)

it should be:

'{2}'.format(name, command.strip(), family))

::: i.e. the closing parenthesis for the call to format() is in the wrong spot. Applying the fix fixes the issue here.

Cheers

ghost avatar Mar 18 '14 11:03 ghost

Fixed by #11392

s0undt3ch avatar Mar 20 '14 20:03 s0undt3ch

The same issue exists with the iptables.insert

     Changes:   
----------
          ID: httpd-443
    Function: iptables.insert
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1379, in call
                  self.verify_ret(ret)
                File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
                  self.gen.throw(type, value, traceback)
                File "/usr/lib/python2.6/site-packages/salt/utils/context.py", line 43, in func_globals_inject
                  yield
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1378, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.6/site-packages/salt/states/iptables.py", line 328, in insert
                  '{1} for {2}'.format(name, command.strip()), family)
              IndexError: tuple index out of range

salt --versions
           Salt: 2014.1.3
         Python: 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
         Jinja2: unknown
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
         PyYAML: 3.10
          PyZMQ: 2.2.0.1
            ZMQ: 3.2.4

fixing the parenthesis fixes the issue.

          ID: httpd-443
    Function: iptables.insert
      Result: True
     Comment: Set and Saved iptables rule for httpd-443 to: iptables -t filter -I INPUT 4 -p tcp -m tcp --dport 443 --jump ACCEPT for ipv4
     Changes:   
              ----------
              locale:
                  httpd-443

cingeyedog avatar Apr 25 '14 20:04 cingeyedog