CiscoDevNet / ansible-dcnm

Apache License 2.0
47 stars 37 forks source link

Adding a control parameter `use_desc_as_key` to the `dcnm_policy` module #279

Open dsx1123 opened 8 months ago

dsx1123 commented 8 months ago

Community Note

Description

The policy in DCNM/NDFC is using policy ID as the key in the backend which creates the problem of idempotency for Ansible, we created a parameter called create_additional_policy which can be used to prevent duplicated policy get created if the policy is not changed. However, if the user would like to modify or delete the policy, the user must use the policy ID to identify the policy that he/she would like to modify.

The notion of this proposal is to treat the description of policy as key to identifying the policy within the switch scope.

New or Affected modules(s):

NDFC version

Potential ansible task config

# Copy-paste your ansible playbook
    - name: Create policy for k8s subnet peering
      cisco.dcnm.dcnm_policy:
        fabric: "{{ fabric }}"
        state: merged
        use_desc_as_key: true     #  default is false
        config:
          - name: switch_freeform
            description: "bgp peer {{ k8s_node_subnet }}"
            policy_vars:
              CONF: "{{ lookup('template', 'templates/k8s_ibgp_peer.tmpl.j2') }}"
          - switch:
            - ip: 172.31.217.122
            - ip: 172.31.217.123
            - ip: 172.31.219.7
            - ip: 172.31.217.102

behavior:

References

Additional context Add any other context or screenshots about the feature request here.