|
|
@ -321,12 +321,12 @@ def main():
|
|
|
|
to_ip=dict(type='str', default='any', aliases=['dest', 'to']),
|
|
|
|
to_ip=dict(type='str', default='any', aliases=['dest', 'to']),
|
|
|
|
to_port=dict(type='str', aliases=['port']),
|
|
|
|
to_port=dict(type='str', aliases=['port']),
|
|
|
|
proto=dict(type='str', aliases=['protocol'], choices=['ah', 'any', 'esp', 'ipv6', 'tcp', 'udp', 'gre', 'igmp']),
|
|
|
|
proto=dict(type='str', aliases=['protocol'], choices=['ah', 'any', 'esp', 'ipv6', 'tcp', 'udp', 'gre', 'igmp']),
|
|
|
|
app=dict(type='str', aliases=['name']),
|
|
|
|
name=dict(type='str', aliases=['app']),
|
|
|
|
comment=dict(type='str'),
|
|
|
|
comment=dict(type='str'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
|
|
|
supports_check_mode=True,
|
|
|
|
mutually_exclusive=[
|
|
|
|
mutually_exclusive=[
|
|
|
|
['app', 'proto', 'logging'],
|
|
|
|
['name', 'proto', 'logging'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
required_one_of=([command_keys]),
|
|
|
|
required_one_of=([command_keys]),
|
|
|
|
required_by=dict(
|
|
|
|
required_by=dict(
|
|
|
@ -496,7 +496,7 @@ def main():
|
|
|
|
if relative_to_cmd == 'zero':
|
|
|
|
if relative_to_cmd == 'zero':
|
|
|
|
insert_to = params['insert']
|
|
|
|
insert_to = params['insert']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
(_, numbered_state, _) = module.run_command([ufw_bin, 'status', 'numbered'])
|
|
|
|
(dummy, numbered_state, dummy) = module.run_command([ufw_bin, 'status', 'numbered'])
|
|
|
|
numbered_line_re = re.compile(R'^\[ *([0-9]+)\] ')
|
|
|
|
numbered_line_re = re.compile(R'^\[ *([0-9]+)\] ')
|
|
|
|
lines = [(numbered_line_re.match(line), '(v6)' in line) for line in numbered_state.splitlines()]
|
|
|
|
lines = [(numbered_line_re.match(line), '(v6)' in line) for line in numbered_state.splitlines()]
|
|
|
|
lines = [(int(matcher.group(1)), ipv6) for (matcher, ipv6) in lines if matcher]
|
|
|
|
lines = [(int(matcher.group(1)), ipv6) for (matcher, ipv6) in lines if matcher]
|
|
|
@ -524,11 +524,11 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
for (key, template) in [('from_ip', "from %s"), ('from_port', "port %s"),
|
|
|
|
for (key, template) in [('from_ip', "from %s"), ('from_port', "port %s"),
|
|
|
|
('to_ip', "to %s"), ('to_port', "port %s"),
|
|
|
|
('to_ip', "to %s"), ('to_port', "port %s"),
|
|
|
|
('proto', "proto %s"), ('app', "app '%s'")]:
|
|
|
|
('proto', "proto %s"), ('name', "app '%s'")]:
|
|
|
|
value = params[key]
|
|
|
|
value = params[key]
|
|
|
|
cmd.append([value, template % (value)])
|
|
|
|
cmd.append([value, template % (value)])
|
|
|
|
|
|
|
|
|
|
|
|
ufw_major, ufw_minor, _ = ufw_version()
|
|
|
|
ufw_major, ufw_minor, dummy = ufw_version()
|
|
|
|
# comment is supported only in ufw version after 0.35
|
|
|
|
# comment is supported only in ufw version after 0.35
|
|
|
|
if (ufw_major == 0 and ufw_minor >= 35) or ufw_major > 0:
|
|
|
|
if (ufw_major == 0 and ufw_minor >= 35) or ufw_major > 0:
|
|
|
|
cmd.append([params['comment'], "comment '%s'" % params['comment']])
|
|
|
|
cmd.append([params['comment'], "comment '%s'" % params['comment']])
|
|
|
|