CiscoDevNet / ansible-dcnm

Apache License 2.0
47 stars 37 forks source link

`dcnm_policy` deploys wrong policy -switch_freefrom #202

Closed jgomezve closed 5 months ago

jgomezve commented 1 year ago

Community Note

Ansible Version and collection version

Affected module(s)

Ansible Playbook

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

  - name: Create policy including required variables
    cisco.dcnm.dcnm_policy:
      fabric: SIMPL-BROWNFIELD
      config:
        - name: switch_freeform               # This must be a valid template name
          description: TESTING_ANSIBLE
          policy_vars:
            CONF: "ip domain-name at"
        - switch:
            - ip: 1.2.3.4
              name: switch_freeform   
              description: TESTING_ANSIBLE
              policy_vars:
                CONF: "ip domain-name at"

Debug Output

changed: [NDFC-FRA] => {
    "changed": true,
    "diff": [
        {
            "deleted": [],
            "deploy": [
                {
                    "name": "switch_freeform",
                    "serialNo": "FDO2139044J"
                }
            ],
            "merged": [
                {
                    "description": "TESTING_ANSIBLE",
                    "entityName": "SWITCH",
                    "entityType": "SWITCH",
                    "nvPairs": {
                        "CONF": "ip domain-name at"
                    },
                    "priority": 500,
                    "serialNumber": "FDO2139044J",
                    "source": "",
                    "templateName": "switch_freeform"
                }
            ],
            "query": [],
            "skipped": []
        }
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "description": "TESTING_ANSIBLE",
                    "name": "switch_freeform",
                    "policy_vars": {
                        "CONF": "ip domain-name at"
                    }
                },
                {
                    "switch": [
                        {
                            "description": "TESTING_ANSIBLE",
                            "ip": "10.122.18.114",
                            "name": "switch_freeform",
                            "policy_vars": {
                                "CONF": "ip domain-name at"
                            }
                        }
                    ]
                }
            ],
            "deploy": true,
            "fabric": "SIMPL-BROWNFIELD",
            "state": "merged"
        }
    },
    "response": [
        {
            "DATA": {
                "successList": [
                    {
                        "message": "POLICY-261550",
                        "name": "FDO2139044J",
                        "status": "Success"
                    }
                ]
            },
            "MESSAGE": "OK",
            "METHOD": "POST",
            "REQUEST_PATH": "https://10.12.1.7:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/bulk-create",
            "RETURN_CODE": 200
        },
        {
            "DATA": [
                {
                    "successPTIList": "POLICY-249920",
                    "switchSN": "FDO2139044J"
                }
            ],
            "MESSAGE": "OK",
            "METHOD": "POST",
            "REQUEST_PATH": "https://10.12.1.7:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/deploy",
            "RETURN_CODE": 200
        }
    ]
}

Note that the policy ID received after creating the policy is the different from the one used to deploy the policy

Expected Behavior

Freeform policy is configured on the NDFC and deployed on the switch

Actual Behavior

Freeform policy is configured on the NDFC but a wrong Policy ID is deployed. Policy in the playbook is not deployed

Steps to Reproduce

Execute the Ansible Playbook

mmudigon commented 1 year ago

@jgomezve

Thanks for raising the issue. We will look into this and update you