Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dncm_policy does not delete policies based on Policy ID #201

Open
jgomezve opened this issue Feb 24, 2023 · 6 comments
Open

dncm_policy does not delete policies based on Policy ID #201

jgomezve opened this issue Feb 24, 2023 · 6 comments
Labels
question Further information is requested

Comments

@jgomezve
Copy link

jgomezve commented Feb 24, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Ansible Version and collection version

  • ansible [core 2.12.3]

DCNM version

  • 12.1.2e

Affected module(s)

  • dcnm_policy

Ansible Playbook

---
- name: Create a Policies in the Nexus Dashboard Fabric Controller
  hosts: ndfc
  gather_facts: no
  tasks:

  - name: Delete policies using policy-id
    cisco.dcnm.dcnm_policy:
      fabric: "SIMPL-BROWNFIELD"
      state: deleted          # only choose form [merged, deleted, query]
      config:
        - name: POLICY-261210  # name is mandatory
          switch:
            - ip: 1.2.3.4

Debug Output

PLAY [Create a Policies in the Nexus Dashboard Fabric Controller] ******************************************************************************

TASK [Delete policies using policy-id] *****************************************************************************************************
ok: [NDFC-FRA]

PLAY RECAP *********************************************************************************************************************************
NDFC-FRA   

Expected Behavior

Policy is deleted

Actual Behavior

Policy is not deleted

Steps to Reproduce

Execute the playbook. The example is taken from the collection documentation

@mmudigon
Copy link
Collaborator

@jgomezve,

Thanks for raising the issue. Can you please give me the complete playbook that you used to create and delete the policy? We will check this and get back to you. If possible please collect ans share the output after executing the command with "-vvvvv" options.

@dsx1123
Copy link

dsx1123 commented Feb 27, 2023

@mmudigon above playbook is enough to recreate this issue, here is the playbook:

---
- name: Delete a Policy in the Nexus Dashboard Fabric Controller
  hosts: ndfc2
  gather_facts: no
  tasks:
  - name: Delete policies using policy-id
    cisco.dcnm.dcnm_policy:
      fabric: "fabric_n9kv"
      state: deleted
      config:
        - name: "POLICY-592740"
          switch:
            - ip: 192.168.123.13

and vvvv output:
https://gist.github.com/dsx1123/f527ef06f743a478cef9e8953472bfe1

@mmudigon
Copy link
Collaborator

The format of the playbook is not correct. The "switch" element is a separate item under "config" and should not be under policies. The correct format is as below:

---
- name: Delete a Policy in the Nexus Dashboard Fabric Controller
  hosts: ndfc2
  gather_facts: no
  tasks:
  - name: Delete policies using policy-id
    cisco.dcnm.dcnm_policy:
      fabric: "fabric_n9kv"
      state: deleted
      config:
        - name: "POLICY-592740"
        - switch:
            - ip: 192.168.123.13

Please try this and let me know

@mmudigon
Copy link
Collaborator

mmudigon commented Feb 28, 2023 via email

@jgomezve
Copy link
Author

jgomezve commented Feb 28, 2023

@mmudigon Thanks for you input.

I have tried the playbook below and it does not work. The playbook hangs forever

---
- name: Create a Policies in the Nexus Dashboard Fabric Controller
  hosts: ndfc
  gather_facts: no
  tasks:

  - name: Delete policies using policy-id
    cisco.dcnm.dcnm_policy:
      fabric: "SIMPL-BROWNFIELD"
      state: deleted          # only choose form [merged, deleted, query]
      config:
        - name: POLICY-262440  # name is mandatory
        - switch: 
          - ip: 1.2.3.4

Why is the key switch another item inside the list config? In my personal opinion this is misleading for users. The way I see it, the list config is the list of policies to be deleted, each of them with its attributes (name, ip)

Moreover, Why is the switch ip required to delete a policy based on policyId ? According to the REST API Documentation, A policy can be deleted based solely on the Policy ID because a policy maps to a single switch

@mmudigon
Copy link
Collaborator

mmudigon commented Mar 1, 2023 via email

@mikewiebe mikewiebe added the question Further information is requested label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants