PaloAltoNetworks/pan-os-ansible

state: merged doesn't merge deep enough.

torch183 opened this issue · 1 comments

Describe the bug

I guess it's up for debate whether this qualifies as a bug report or a feature request, but when configuring an object that has attributes that are lists, the list contents are not merged, but replaced.

Expected behavior

If I run a task including panos_address_object with state: merged on an existing object that has a list of tags assigned to it, and I supply a new list of tags, I would expect the object to have both the new and the old tags.

Current behavior

Instead the old list of tags is replaced with the new list

Possible solution

Update the merged state to merge deeper/recursively

Steps to reproduce

Make the following tasks

- name: Create a host object
  panos_address_object:
    provider: "{{ provider }}"
    state: present
    name: host1
    value: 1.2.3.4
    tag:
    - tag1
    - tag2

- name: Update tags
  panos_address_object:
    provider: "{{ provider }}"
    state: merged
    name: host1
    tag:
    - tag3
    - tag4

Afterwards the object will only have tag3 and tag4 assigned

Context

As mentioned, I'd like to use Ansible to update tags on objects. I'd also like to be able to add/remove an address object to/from a security rule without having to explicitly extract and manipulate the list of sources/destinations, etc.

Your Environment

Ansible Automation Platform Controller 4.4.7

  • Collection: 2.17.5
  • Python: 3.9.16
  • Ansible: core 2.15.4
  • PAN-OS Python Library & version (e.g. pandevice 0.14.0, pan-os-python 1.0.2): pan-os-python==1.11.0, pan-python==0.17.0

For some reason, I'm not able to reproduce this now. Could be an error in my previous testing. Please ignore