From c71714c364375f1ea388c7db8c287f8052cb865e Mon Sep 17 00:00:00 2001 From: Stephen Spencer Date: Sat, 9 May 2015 16:30:30 -0500 Subject: [PATCH] short-circuit auto-failure of iptables.delete state if position argument is set without the other accoutrements that check_rule requires. --- salt/states/iptables.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/salt/states/iptables.py b/salt/states/iptables.py index 8b4d89947e..b08a08b529 100644 --- a/salt/states/iptables.py +++ b/salt/states/iptables.py @@ -601,16 +601,18 @@ def delete(name, family='ipv4', **kwargs): kwargs['name'] = name rule = __salt__['iptables.build_rule'](family=family, **kwargs) command = __salt__['iptables.build_rule'](full=True, family=family, command='D', **kwargs) + if not __salt__['iptables.check'](kwargs['table'], kwargs['chain'], rule, family) is True: - ret['result'] = True - ret['comment'] = 'iptables rule for {0} already absent for {1} ({2})'.format( - name, - family, - command.strip()) - return ret + if 'position' not in kwargs: + ret['result'] = True + ret['comment'] = 'iptables rule for {0} already absent for {1} ({2})'.format( + name, + family, + command.strip()) + return ret if __opts__['test']: ret['comment'] = 'iptables rule for {0} needs to be deleted for {1} ({2})'.format( name,