Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meraki_mx_l3_firewall - Fix firewall rules not updating #62

Merged
merged 2 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions plugins/modules/meraki_mx_l3_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,22 @@
dest_port:
description:
- Comma separated list of destination port numbers to match against.
- C(Any) must be capitalized.
type: str
dest_cidr:
description:
- Comma separated list of CIDR notation destination networks.
- C(Any) must be capitalized.
type: str
src_port:
description:
- Comma separated list of source port numbers to match against.
- C(Any) must be capitalized.
type: str
src_cidr:
description:
- Comma separated list of CIDR notation source networks.
- C(Any) must be capitalized.
type: str
comment:
description:
Expand Down Expand Up @@ -299,9 +303,14 @@ def main():
if update is False:
default_rule = rules[len(rules) - 1].copy()
del rules[len(rules) - 1] # Remove default rule for comparison
for r in range(len(rules) - 1):
if meraki.is_update_required(rules[r], payload['rules'][r]) is True:
if len(rules) - 1 == 0:
if meraki.is_update_required(rules[0], payload['rules'][0]) is True:
# meraki.fail_json(msg="Compare", original=rules[0], payload=payload['rules'][0])
update = True
else:
for r in range(len(rules) - 1):
if meraki.is_update_required(rules[r], payload['rules'][r]) is True:
update = True
rules.append(default_rule)
except KeyError:
pass
Expand Down
49 changes: 37 additions & 12 deletions tests/integration/targets/meraki_mx_l3_firewall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand Down Expand Up @@ -69,8 +69,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand Down Expand Up @@ -98,8 +98,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand All @@ -115,6 +115,31 @@
- create_one_idempotent.changed == False
- create_one_idempotent.data is defined

- name: Update one existing rule
meraki_mx_l3_firewall:
auth_key: '{{ auth_key }}'
org_name: '{{test_org_name}}'
net_name: TestNetAppliance
state: present
rules:
- comment: Deny all documentation addresses
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32,192.0.1.2/32
protocol: tcp
policy: deny
delegate_to: localhost
register: update_one

- debug:
msg: '{{update_one}}'

- assert:
that:
- update_one.changed == True
- update_one.data is defined

- name: Create syslog in network
meraki_syslog:
auth_key: '{{ auth_key }}'
Expand All @@ -137,8 +162,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand All @@ -165,8 +190,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand Down Expand Up @@ -207,8 +232,8 @@
state: present
rules:
- comment: Deny to documentation address
src_port: any
src_cidr: any
src_port: Any
src_cidr: Any
dest_port: 80,443
dest_cidr: 192.0.1.1/32
protocol: tcp
Expand Down