Skip to content

Commit ca5545b

Browse files
fix: Handle rule location
1 parent 139bb22 commit ca5545b

6 files changed

Lines changed: 71 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Automatic New Policy Creation
2+
3+
When requests for access fall through and miss the preset policies, it is useful to be able to automate the policy
4+
creation anyway to prevent duplication.
5+
6+
This repository includes handling for creating new policies by following this basic process:
7+
8+
1. Resolve source/destination IP to zones
9+
2. Check the policy is actually required using `test security-policy match`
10+
3. Add the required objects
11+
4. Add the security rule, using your specified location logic
12+
13+
!!! warning
14+
This automation does no computation of "rule location". You should either group your rules by specifying a rule
15+
to add all automated rules below using the `default_location_rule_name` and `default_rule_location` variables.
16+
17+
Without any changes, `add_policy.yml` will automatically add new policy and run through the zone resolution and test
18+
process.
19+
20+
```shell
21+
ansible-playbook playbooks/orchestrator/lab_policy.yml
22+
```
23+
24+
![img.png](run_lab_create_new_policy.png)
25+
26+
## Zone resolution behavior
27+
28+
When a new policy is necessary, Panorama is queried for all of the connected devices, then we run a FIB lookup on each,
29+
then take the outgoing interface and match it to a zone based on `show interface`.
30+
31+
Because of this, we may resolve the one IP address to several zones.
32+
33+
## Test behavior
34+
35+
Before adding a new rule, we test the traffic based on the provided source/destination and application on each
36+
firewall connected to panorama. If the traffic is not already allowed, the creation will continue.
37+

docs/user_guide/preset_policy.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,16 @@ Run the `lab_policy.yml` playbook to deploy the policy.
137137
```shell
138138
ansible-playbook playbooks/orchestrator/lab_policy.yml
139139
```
140+
141+
In this example, `lab_policy` will prompt for the SIP/DIP values and the application. In your environment, you may
142+
trigger this playbook (or another playbook for a different set of hosts) using EDA or any other system that can
143+
populate these values.
144+
145+
You will see the policy is matched and the relevant address groups updated.
146+
147+
![img.png](run_lab_policy.png)
148+
149+
## What next?
150+
151+
So, what happens for policies that don't match any preset policies? Proceed to the [New Policy Creation](new_policy_creation.md)
152+
guide.
12.2 KB
Loading

docs/user_guide/run_lab_policy.png

21.6 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ nav:
4343
- User Guide:
4444
- Introduction: user_guide/introduction.md
4545
- Preset Policy: user_guide/preset_policy.md
46+
- New Policy Creation: user_guide/new_policy_creation.md
4647
- Changelog: CHANGELOG.md
4748

4849
extra:

playbooks/orchestrator/new/create_policy.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
description: "Auto-created address object"
4242
state: present
4343

44-
- name: Create the SECURITY RULE
44+
- name: Create the SECURITY RULE positional
4545
paloaltonetworks.panos.panos_security_rule:
4646
provider: "{{ provider }}"
4747
device_group: "{{ device_group }}"
@@ -54,6 +54,25 @@
5454
destination_ip: ["{{ destination_ip }}"]
5555
application: ["{{ application }}"]
5656
action: "allow"
57+
location: "{{ default_rule_location }}"
58+
existing_rule: "{{ default_location_rule_name | default('') }}"
59+
when: default_location_rule_name is defined
60+
61+
- name: Create the SECURITY RULE default
62+
paloaltonetworks.panos.panos_security_rule:
63+
provider: "{{ provider }}"
64+
device_group: "{{ device_group }}"
65+
rule_name: "{{ rule_name }}"
66+
description: "Created by automation at {{ ansible_date_time.epoch }}"
67+
tag_name: ["{{ tag }}"]
68+
source_zone: "{{ source_zones }}"
69+
source_ip: ["{{ source_ip }}"]
70+
destination_zone: "{{ destination_zones }}"
71+
destination_ip: ["{{ destination_ip }}"]
72+
application: ["{{ application }}"]
73+
action: "allow"
74+
location: "{{ default_rule_location }}"
75+
when: default_location_rule_name is not defined
5776

5877
- name: Update facts
5978
set_fact:

0 commit comments

Comments
 (0)