CiscoDevNet / ansible-dcnm

Apache License 2.0
45 stars 36 forks source link

policy is not created when it is added first time #212

Closed dsx1123 closed 1 year ago

dsx1123 commented 1 year ago

Community Note

Ansible Version and collection version

ansible [core 2.12.10]
  config file = /root/.ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/virtualenv/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/virtualenv/ansible/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

NDFC version

Affected module(s)

Ansible Playbook

---
- name: Create a policy first time
  hosts: ndfc2
  gather_facts: no
  tasks:
  - name: create policy
    cisco.dcnm.dcnm_policy:
      fabric: fabric_n9kv
      config:
        - name: feature_netflow
          create_additional_policy: false
          priority: 101
        - switch:
          - ip: 192.168.123.13

Debug Output

ansible-playbook [core 2.12.10]
  config file = /root/.ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/virtualenv/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/virtualenv/ansible/bin/ansible-playbook
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
Using /root/.ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection cisco.dcnm from /root/.ansible/collections/ansible_collections/cisco/dcnm
Loading callback plugin default of type stdout, v2.0 from /root/virtualenv/ansible/lib/python3.9/site-packages/ansible/plugins/callback/default.py
Loading collection ansible.posix from /root/.ansible/collections/ansible_collections/ansible/posix
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
Loading callback plugin ansible.posix.profile_tasks of type aggregate, v2.0 from /root/.ansible/collections/ansible_collections/ansible/posix/plugins/callback/profile_tasks.py

PLAYBOOK: policy_create.yaml *********************************************************************************************************************************************************************************************************************
Positional arguments: policy_create.yaml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in policy_create.yaml

PLAY [Create a policy first time] ****************************************************************************************************************************************************************************************************************
Trying secret FileVaultSecret(filename='/root/.vault_pass') for vault_id=default
META: ran handlers

TASK [create policy] *****************************************************************************************************************************************************************************************************************************
task path: /root/workspace/ansible/dcnm/misc/policy_create.yaml:6
Tuesday 14 March 2023  21:11:38 -0700 (0:00:00.078)       0:00:00.078 *********
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
<shdu-ndfc-2.cisco.com> attempting to start connection
<shdu-ndfc-2.cisco.com> using connection plugin ansible.netcommon.httpapi
Found ansible-connection at path /root/virtualenv/ansible/bin/ansible-connection
<shdu-ndfc-2.cisco.com> local domain socket does not exist, starting it
<shdu-ndfc-2.cisco.com> control socket path is /root/.ansible/pc/b5f087ebc8
<shdu-ndfc-2.cisco.com> redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
<shdu-ndfc-2.cisco.com> Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
<shdu-ndfc-2.cisco.com> Loading collection cisco.dcnm from /root/.ansible/collections/ansible_collections/cisco/dcnm
<shdu-ndfc-2.cisco.com> local domain socket listeners started successfully
<shdu-ndfc-2.cisco.com> loaded API plugin ansible_collections.cisco.dcnm.plugins.httpapi.dcnm from path /root/.ansible/collections/ansible_collections/cisco/dcnm/plugins/httpapi/dcnm.py for platform type cisco.dcnm.dcnm
<shdu-ndfc-2.cisco.com>
<shdu-ndfc-2.cisco.com> local domain socket path is /root/.ansible/pc/b5f087ebc8
<shdu-ndfc-2.cisco.com> ESTABLISH LOCAL CONNECTION FOR USER: root
<shdu-ndfc-2.cisco.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-717974s2rrhps6 `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505 `" && echo ansible-tmp-1678853498.8023677-717978-94017690942505="` echo /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/cisco/dcnm/plugins/modules/dcnm_policy.py
<shdu-ndfc-2.cisco.com> PUT /root/.ansible/tmp/ansible-local-717974s2rrhps6/tmpyn93hxib TO /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505/AnsiballZ_dcnm_policy.py
<shdu-ndfc-2.cisco.com> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505/ /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505/AnsiballZ_dcnm_policy.py && sleep 0'
<shdu-ndfc-2.cisco.com> EXEC /bin/sh -c '/root/virtualenv/ansible/bin/python /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505/AnsiballZ_dcnm_policy.py && sleep 0'
<shdu-ndfc-2.cisco.com> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-717974s2rrhps6/ansible-tmp-1678853498.8023677-717978-94017690942505/ > /dev/null 2>&1 && sleep 0'
ok: [shdu-ndfc-2.cisco.com] => {
    "changed": false,
    "diff": [
        {
            "deleted": [],
            "deploy": [
                {
                    "name": "feature_netflow",
                    "serialNo": "93B6CP4V0EW"
                }
            ],
            "merged": [
                {
                    "description": "",
                    "entityName": "SWITCH",
                    "entityType": "SWITCH",
                    "nvPairs": {},
                    "priority": 101,
                    "serialNumber": "93B6CP4V0EW",
                    "source": "",
                    "templateName": "feature_netflow"
                }
            ],
            "query": [],
            "skipped": []
        }
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "create_additional_policy": false,
                    "name": "feature_netflow",
                    "priority": 101
                },
                {
                    "switch": [
                        {
                            "ip": "192.168.123.13"
                        }
                    ]
                }
            ],
            "deploy": true,
            "fabric": "fabric_n9kv",
            "state": "merged"
        }
    },
    "response": [
        {
            "DATA": {
                "successList": [
                    {
                        "message": "POLICY-803750",
                        "name": "93B6CP4V0EW",
                        "status": "Success"
                    }
                ]
            },
            "MESSAGE": "OK",
            "METHOD": "POST",
            "REQUEST_PATH": "https://shdu-ndfc-2.cisco.com:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/bulk-create",
            "RETURN_CODE": 200
        }
    ]
}
META: ran handlers
META: ran handlers

PLAY RECAP ***************************************************************************************************************************************************************************************************************************************
shdu-ndfc-2.cisco.com      : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Tuesday 14 March 2023  21:11:39 -0700 (0:00:01.316)       0:00:01.395 *********
===============================================================================
create policy ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1.32s
/root/workspace/ansible/dcnm/misc/policy_create.yaml:6 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expected Behavior

As template feature_netflow was never attached to switch 192.168.123.13 before, it should be added to NDFC and deployed to switch

Actual Behavior

ansible return ok, and policy is not added to NDFC

Steps to Reproduce

References

mikewiebe commented 1 year ago

Looks like this is probably fixed by https://github.com/CiscoDevNet/ansible-dcnm/pull/203

mmudigon commented 1 year ago

@dsx1123 Since you have verified that this issue is not seen with changes from policy-fix-201-202 branch, I am closing this.