Open sinontaylor opened 1 year ago
:tada: Thanks for opening your first issue here! Welcome to the community!
Hi @sinontaylor, I can't reproduce this one. I tried:
In PAN-OS, you can only have one security profile group attached to a rule, so a string does seem correct as opposed to a list.
What was the error, and are you able to share the code being used maybe?
hi, so the error was this:
"msg": "Failed apply: INC1480768-1 -> profile-setting -> group '['security-profile-group']' is not a valid reference\n INC1480768-1 -> profile-setting is invalid"
In the playbook I am editing existing rules (just the source/destination fields using the difference filter). For group_profile (which is present on the rules) I'm not changing it:
group_profile: '{{ rule.group_profile | default(omit, true) }}'
I see there was a similar issue in the old module. https://github.com/PaloAltoNetworks/ansible-pan/issues/483
Hi @sinontaylor, it looks like the gathering is bringing back a list of strings, that's the root cause. Your workaround to patch the code to accept a list works for you and would only work for a list of a single string. The other workaround would be to use group_profile: "{{ rule.group_profile[0] | default(omit, true) }}"
. The input to group_profile
should be a string not a list though, PAN-OS only accepts one Security Profile Group per rule, so the fix is in the gathering part of the module, not the configuration setting part of the module.
@jamesholland-uk, thanks for looking at this (and for all the other work btw (pan-ansible is great!)). As you point out its in the collection. I did a quick test and we can see panos_security_rule_facts returns a list for group_profile:
name: Get the definition of device group '{{item.mmc_device_group }}' security rule '{{ item.mmc_rule }}'
paloaltonetworks.panos.panos_security_rule_facts:
provider: '{{ lab_provider }}'
device_group: "{{ item.mmc_device_group | quote }}"
rule_name: '{{ item.mmc_rule }}'
register: result
- name: print
debug:
msg: "{{ result }}"
yields:
"rule_details": [
{
"action": "allow",
"antivirus": null,
"application": [
"any"
],
"category": [
"any"
],
"data_filtering": null,
"description": "PASSES",
"destination_devices": [
"any"
],
"destination_ip": [
"H-8.8.8.8-32"
],
"destintaion_zone": [
"any"
],
"disable_server_response_inspection": false,
"disabled": true,
"file_blocking": null,
"group_profile": [
"security-profile-group"
],
I'll use your suggestion above.
Describe the bug
editing rule throws an error when group profile is used
Expected behavior
faithfully edit rule
Current behavior
invalid for group_profile
Possible solution
I simply edited local copy of panos_security_rule.py: group_profile=dict(type="list", element="str", default="[any"]),
Working now for me.
Your Environment