Browse Source

Adds "Rule inserted" validation

tags/v0.2.0
Rob Ruana 6 years ago
parent
commit
dd1c4b34a5
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      _states/ufw.py

+ 6
- 0
_states/ufw.py View File

return _error(name, e.message) return _error(name, e.message)


adds = False adds = False
inserts = False
updates = False updates = False
for line in out.split('\n'): for line in out.split('\n'):
if re.match('^Skipping', line): if re.match('^Skipping', line):
if re.match('^Rule(s)? added', line): if re.match('^Rule(s)? added', line):
adds = True adds = True
break break
if re.match('^Rule(s)? inserted', line):
inserts = True
break
if re.match('^Rule(s)? updated', line): if re.match('^Rule(s)? updated', line):
updates = True updates = True
break break


if adds: if adds:
return _changed(name, "{0} added".format(name), rule=rule) return _changed(name, "{0} added".format(name), rule=rule)
elif inserts:
return _changed(name, "{0} inserted".format(name), rule=rule)
elif updates: elif updates:
return _changed(name, "{0} updated".format(name), rule=rule) return _changed(name, "{0} updated".format(name), rule=rule)
else: else:

Loading…
Cancel
Save