aristanetworks / ansible-cvp

Ansible modules for Arista CloudVision
http://cvp.avd.sh
Apache License 2.0
66 stars 61 forks source link

[BUG] task not running after using cv_task to execute #79

Closed bluecarrot closed 4 years ago

bluecarrot commented 4 years ago

Issue Type

Module Name cv_tasks

`arista.cvp` collection 1.0.0
Python libraries version
Package                          Version
-------------------------------- -------
ansible                          2.9.0
Babel                            0.9.6
backports.ssl-match-hostname     3.5.0.1
cffi                             1.6.0
chardet                          2.2.1
cloud-init                       0.7.9
configobj                        4.7.2
cryptography                     1.7.2
cvprac                           1.0.1
decorator                        3.4.0
enum34                           1.0.4
futures                          3.1.1
fuzzywuzzy                       0.17.0
httplib2                         0.9.2
idna                             2.4
iniparse                         0.4
ipaddress                        1.0.16
IPy                              0.75
Jinja2                           2.7.2
jmespath                         0.9.0
jsonpatch                        1.2
jsonpointer                      1.9
kitchen                          1.1.1
MarkupSafe                       0.11
meld3                            0.6.10
mercurial                        2.6.2
paramiko                         2.1.1
passlib                          1.6.5
perf                             0.1
pip                              19.3.1
ply                              3.4
policycoreutils-default-encoding 0.1
prettytable                      0.7.2
psycopg2                         2.5.1
pyasn1                           0.1.9
pycparser                        2.14
pycurl                           7.19.0
pygobject                        3.22.0
pygpgme                          0.3
pyliblzma                        0.5.3
pyserial                         2.6
python-linux-procfs              0.4.9
pyudev                           0.15
pyxattr                          0.5.1
PyYAML                           3.10
rcvpapi                          1.5.31
requests                         2.6.0
schedutils                       0.4
seobject                         0.1
sepolicy                         1.1
setuptools                       0.9.8
six                              1.9.0
supervisor                       3.1.4
urlgrabber                       3.10
urllib3                          1.10.2
virtualenv                       15.1.0
yum-metadata-parser              1.1.4

OS / Environment

CentOS Linux release 7.5.1804 (Core)

Summary

i created a playbook to update the configlet of leaf

---
- name: Test cv_device
  hosts: all
  connection: local
  gather_facts: no
  collections:
    - arista.cvp
    - arista.cvp
  vars:
    configlet_list:
      t_a_configlet: "!\nvlan {{ vlan_no }}\n   name {{ tenant_name }}\n!\nvrf instance {{ tenant_name }}\n!\ninterface Vlan{{ vlan_no }}\n   vrf {{ tenant_name }}\n   ip address virtual {{ gateway_no }}\n!\ninterface Vxlan1\
    # Device inventory for provision activity: bind configlet
    devices_inventory:
      Leaf01:
        name: Leaf01
        configlets:
          - MLAG-LEAF1
          - eBGP_Underlay_LEAF01
          - RECONCILE_Leaf1
          - t_a_configlet
  tasks:
      # Collect CVP Facts as init process
    - name: "Gather CVP facts from {{inventory_hostname}}"
      cv_facts:
      register: cvp_facts
    - name: 'Create configlets on CVP {{inventory_hostname}}.'
      cv_configlet:
        cvp_facts: "{{cvp_facts.ansible_facts}}"
        configlets: "{{configlet_list}}"
        configlet_filter: ["{{ tenant_name}}"]
      register: cvp_configlet

    # Display information for device before a container's move
    - name: "Configure devices on {{inventory_hostname}}"
      cv_device:
        devices: "{{devices_inventory}}"
        cvp_facts: '{{cvp_facts.ansible_facts}}'
        device_filter: ['Leaf']
      register: cvp_device

    - name: Display cv_device
      debug:
        msg: "{{cvp_device}}"

    - name: 'RUN 1: Execute tasks registered in the previous task'
      cv_task:
        tasks: "{{ cvp_device.data.tasks }}"
      register: cvp_tasks

the tasks output:

TASK [RUN 1: Execute tasks registered in the previous task] ************************************************************************************************************
task path: /opt/arista/cvp_configlet-apply.yml:123
[WARNING]: No actionable tasks found on CVP

ok: [xxxxxx.xxxxxxxx.xxxxxxxxx] => {
    "changed": false,
    "data": {},
    "invocation": {
        "module_args": {
            "state": "executed",
            "tasks": [
                {
                    "actionStatus": "ACTIVE",
                    "currentAction": "Submit",
                    "description": "Ansible Configlet Update: on Device Leaf03",
                    "displayedStutus": "Pending",
                    "name": "",
                    "note": "",
                    "status": "ACTIVE",
                    "taskNo": "74"
                },
                {
                    "actionStatus": "ACTIVE",
                    "currentAction": "Submit",
                    "description": "Ansible Configlet Update: on Device Leaf02",
                    "displayedStutus": "Pending",
                    "name": "",
                    "note": "",
                    "status": "ACTIVE",
                    "taskNo": "75"
                },
                {
                    "actionStatus": "ACTIVE",
                    "currentAction": "Submit",
                    "description": "Ansible Configlet Update: on Device Leaf01",
                    "displayedStutus": "Pending",
                    "name": "",
                    "note": "",
                    "status": "ACTIVE",
                    "taskNo": "76"
                },
                {
                    "actionStatus": "ACTIVE",
                    "currentAction": "Submit",
                    "description": "Ansible Configlet Update: on Device Leaf07",
                    "displayedStutus": "Pending",
                    "name": "",
                    "note": "",
                    "status": "ACTIVE",
                    "taskNo": "77"
                },
                {
                    "actionStatus": "ACTIVE",
                    "currentAction": "Submit",
                    "description": "Ansible Configlet Update: on Device Leaf08",
                    "displayedStutus": "Pending",
                    "name": "",
                    "note": "",
                    "status": "ACTIVE",
                    "taskNo": "78"
                }
            ],
            "wait": 0
        }
    }
}

Steps to reproduce

Please find the playbook code above

Expected results

Pending task to be executed.

Actual results

Unable to run the task.

[WARNING]: No actionable tasks found on CVP
titom73 commented 4 years ago

Hello @bluecarrot

Based on your report, we has identified an issue within cv_device where fields in task were not updated to match cv_task expectation.

Once this change had been done, tasks were correctly captured by cv_device

[...]
TASK [Display cv_device] ************
Monday 18 November 2019  17:27:33 +0100 (0:00:17.133)       0:01:06.946 ******* 
ok: [cvp_foster] => {
    "msg": {
        "changed": true, 
        "data": {
            "new": [], 
            "reset": [], 
            "tasks": [
                {
                    "currentTaskName": "Submit", 
                    "description": "Configlet Assign: veos01", 
                    "note": "", 
                    "taskStatus": "ACTIVE", 
                    "workOrderDetails": {
                        "ipAddress": "172.23.0.2", 
                        "netElementHostName": "veos01", 
                        "netElementId": "50:25:22:56:12:61", 
                        "serialNumber": "728870FA16465700865C770C620DF4DE", 
                        "workOrderDetailsId": "", 
                        "workOrderId": ""
                    }, 
                    "workOrderId": "161", 
                    "workOrderState": "ACTIVE", 
                    "workOrderUserDefinedStatus": "Pending"
                }
            ], 
            "updated": [
                {
                    "veos01": "Configlets-[u'161']"
                }
            ]
        }, 
        "failed": false
    }
}

TASK [RUN 1: Execute tasks registered in the previous task] ************
Monday 18 November 2019  17:27:34 +0100 (0:00:01.151)       0:01:08.097 ******* 
changed: [cvp_foster]

PLAY RECAP ************
cvp_foster                 : ok=6    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Fix is currently in PR #80 and will be merged once we will validate this change.

Could you check on your own and confirm ?

Thanks

bluecarrot commented 4 years ago

Thanks @titom73 let me test it out and update you.

bluecarrot commented 4 years ago

@titom73 thanks, it works. I will close this issue.