Skip to content

Commit a496036

Browse files
fix: Test command actually implemented properly
1 parent 5fc0197 commit a496036

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

filter_plugins/custom_filters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from json import JSONDecodeError
23
from xml.etree.ElementTree import fromstring
34
from typing import Union
45

@@ -69,6 +70,9 @@ def panos_op_policy_match_result_to_bool(self, data: Union[list, dict]) -> bool:
6970
for op_result in data:
7071
stdout = op_result.get("stdout")
7172
if stdout:
72-
stdout = json.loads(stdout)
73+
try:
74+
stdout = json.loads(stdout)
75+
except JSONDecodeError:
76+
return False
7377
if stdout.get("response").get("result"):
7478
return True

playbooks/orchestrator/add_policy.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,23 @@
7979
ansible.builtin.include_tasks:
8080
file: new/lookup_policy.yml
8181

82-
- name: RULE creation
83-
ansible.builtin.include_tasks:
84-
file: new/create_policy.yml
85-
86-
- name: Update that the config has changed
87-
ansible.builtin.set_fact:
88-
config_changed: true
82+
- name: Create Rule Block
83+
block:
84+
- name: RULE creation
85+
ansible.builtin.include_tasks:
86+
file: new/create_policy.yml
87+
88+
- name: Update that the config has changed
89+
ansible.builtin.set_fact:
90+
config_changed: true
91+
when:
92+
- not matches_existing_policy
8993

9094
when:
9195
- not policy_match
92-
- source_ip
93-
- destination_ip
94-
- application
96+
- source_ip is defined and source_ip != ""
97+
- destination_ip is defined and destination_ip != ""
98+
- application is defined and application != ""
9599

96100

97101
- name: Commit Block - Triggers on any change

playbooks/orchestrator/preset/user_outbound_policy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
device_group: Lab # Finally, we set the device group!
1111
when:
1212
- "source_ip is defined or source_user is defined"
13-
- url is defined
13+
- url is defined and url != None

0 commit comments

Comments
 (0)