PaloAltoNetworks/pan-os-ansible

panos_nat_rule_facts rule_regex does not accept "$"

tom0010 opened this issue · 2 comments

Describe the bug

When using panos_nat_rule_facts and using rule_regex the module does not accept using $ at the end of the regex to stop the matching.

Expected behavior

The regex matching should work just as regex101 would.

Current behavior

Nothing is matched at all when using $ at the end of the regex.

Possible solution

N/A...🤷‍♂️

Steps to reproduce

  - name: "Collect existing NAT rules in {{ item.key | upper }} on Panorama"
    paloaltonetworks.panos.panos_nat_rule_facts:
      provider:
        ip_address: "panorama.domain.com"
        username: "username"
        password: "{{ ansible_ssh_pass }}"
      rule_regex: ".*{{ my_var }}$"     <--- tried using without a regex group
      rule_regex: ".*({{ my_var }})$"   <--- tried using a regex group too, but the same result
      device_group: "{{ item.key | upper }}"
      rulebase: "post-rulebase"
    register: "result"
fatal: [localhost]: FAILED! => {
    "assertion": "result.listing | length >= 1",
    "changed": false,
    "evaluated_to": false,
    "msg": "my-entry was not found on my_hostname."
}

Screenshots

From regex101, how the regex should react:
image

Context

I'm trying to gather all nat rules and then do a regex to make sure that entry is not configured on the device.

Your Environment

  • Collection: 2.9.0
  • Python: 3.9.4
  • Ansible: 2.9.11
  • PAN-OS Python Library & version (e.g. pandevice 0.14.0, pan-os-python 1.0.2): pan-os-python 1.1.1, pan-python 0.16.0

🎉 Thanks for opening your first issue here! Welcome to the community!

Actually this was stupid, the regex works fine, the issue was that I thought the data was returning something different.
After debugging the module I managed to find out that the data I was using regex over was different than expected.