CiscoDevNet / ansible-dcnm

Apache License 2.0
47 stars 37 forks source link

Policy module fails when using policy as key flag if a policy already exists in NDFC but doesn't have a description field #338

Open mthurstocisco opened 3 weeks ago

mthurstocisco commented 3 weeks ago

Community Note

Ansible Version and collection version

ansible [core 2.16.3]

DCNM version

Affected module(s)

Ansible Playbook

- name: Manage NDFC Fabric Policies
  cisco.dcnm.dcnm_policy:
    fabric: fabric_name
    use_desc_as_key: true
    config: 
        - create_additional_policy: False
          description: feature_ospf
          name: feature_ospf
          policy_vars:
          priority: 60
       - switch:
             - ip: 1.2.3.4
    deploy: false
    state: merged

Debug Output

To hit this problem it would require NDFC to already an instance of the same policy on the same switch but with the description field being blank.

When running you get a key error when the description is currently blank in NDFC (in my example i was trying to create feature_ospf but it was already in NDFC from the fabric creation).

In terms of expected behavior, maybe a error raised up to the user telling them a policy with that template already exists in NDFC but without a description? I guess on brownfield deployments (where potentially you want to start using ansible but have previously configured things via the GUI) this would come up a lot.

Expected Behavior

Actual Behavior

Steps to Reproduce

References

mikewiebe commented 1 week ago

@mthurstocisco we were unable to recreate this in our environment and yours so please add the traceback info if you see it again. We will keep this issue open for a couple of weeks and close it then if the issue cannot be recreated.