rubrikinc / rubrik-modules-for-ansible

Rubrik Modules for Ansible
https://build.rubrik.com/tooling-integrations/ansible/
GNU General Public License v3.0
17 stars 20 forks source link

rubrik job status argument of type 'NoneType' is not iterable #40

Closed zisuu closed 5 years ago

zisuu commented 5 years ago

Expected Behavior

Triggering a On-Demand Snapshot and then query the job status, untill success state:

   - name: On-Demand Snapshot
     connection: local
     rubrik_on_demand_snapshot:
       provider: "{{ credentials }}"
       object_name: "{{ inventory_hostname_short }}"
       object_type: "ahv"
       sla_name: "SLA_Unassigned"
     register: snapshot

   - name: get job status
     connection: local
     rubrik_job_status:
       provider: "{{ credentials }}"
       url: "{{ snapshot.job_status_url }}"

Current Behavior

Running this playbook successfully triggers an On-Demand Snapshot on rubrik for this object, but the rubrik_job_status module seems to fail getting the job status.

Failure Information (for bugs)

TASK [rubrik-vm-snapshot : On-Demand Snapshot] *******************************************************************************************************************************************************************
task path: /etc/ansible/roles/rubrik-vm-snapshot/tasks/main.yml:3
Trying secret FileVaultSecret(filename='/etc/ansible/playbooks/rubrik-vm-snapshot/vault.yaml') for vault_id=default
<LNXTEST2> ESTABLISH LOCAL CONNECTION FOR USER: ansible-deployer
<LNXTEST2> EXEC /bin/sh -c 'echo ~ansible-deployer && sleep 0'
<LNXTEST2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813 `" && echo ansible-tmp-1558705565.13-3029050761813="` echo /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813 `" ) && sleep 0'
<LNXTEST2> Attempting python interpreter discovery
<LNXTEST2> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<LNXTEST2> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /etc/ansible/library/rubrik_on_demand_snapshot.py
<LNXTEST2> PUT /home/ansible-deployer/.ansible/tmp/ansible-local-231295rgIPaM/tmpCDetUU TO /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813/AnsiballZ_rubrik_on_demand_snapshot.py
<LNXTEST2> EXEC /bin/sh -c 'chmod u+x /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813/ /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813/AnsiballZ_rubrik_on_demand_snapshot.py && sleep 0'
<LNXTEST2> EXEC /bin/sh -c '/usr/bin/python /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813/AnsiballZ_rubrik_on_demand_snapshot.py && sleep 0'
<LNXTEST2> EXEC /bin/sh -c 'rm -f -r /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705565.13-3029050761813/ > /dev/null 2>&1 && sleep 0'
changed: [LNXTEST2] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "invocation": {
        "module_args": {
            "fileset": null, 
            "host_os": null, 
            "node_ip": "XXX.XXX.XXX.XXX", 
            "object_name": "LNXTEST2", 
            "object_type": "ahv", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "provider": {
                "node_ip": "XXX.XXX.XXX.XXX", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "username": "ansible"
            }, 
            "sla_name": "SLA_Gold", 
            "username": "ansible"
        }
    }, 
    "job_status_url": "https://XXX.XXX.XXX.XXX/api/internal/nutanix/vm/request/CREATE_NUTANIX_SNAPSHOT_1c38e8aa-3c96-48c0-8535-56f52c6b2b44-vm-ee080f60-e770-4edb-bf81-2c5634a47d3f_160a1493-b25b-4662-95f2-56f52c6b2b44:::0", 
    "response": {
        "id": "CREATE_NUTANIX_SNAPSHOT_1c38e8aa-3c96-48c0-8535-56f52c6b2b44-vm-ee080f60-e770-4edb-bf81-2c5634a47d3f_160a1493-b25b-4662-95f2-56f52c6b2b44:::0", 
        "links": [
            {
                "href": "https://XXX.XXX.XXX.XXX/api/internal/nutanix/vm/request/CREATE_NUTANIX_SNAPSHOT_1c38e8aa-3c96-48c0-8535-56f52c6b2b44-vm-ee080f60-e770-4edb-bf81-2c5634a47d3f_160a1493-b25b-4662-95f2-56f52c6b2b44:::0", 
                "rel": "self"
            }
        ], 
        "progress": 0.0, 
        "startTime": "2019-05-24T13:46:06.299Z", 
        "status": "QUEUED"
    }
}

TASK [rubrik-vm-snapshot : get job status] ***********************************************************************************************************************************************************************
task path: /etc/ansible/roles/rubrik-vm-snapshot/tasks/main.yml:12
Trying secret FileVaultSecret(filename='/etc/ansible/playbooks/rubrik-vm-snapshot/vault.yaml') for vault_id=default
<LNXTEST2> ESTABLISH LOCAL CONNECTION FOR USER: ansible-deployer
<LNXTEST2> EXEC /bin/sh -c 'echo ~ansible-deployer && sleep 0'
<LNXTEST2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330 `" && echo ansible-tmp-1558705566.5-201130080873330="` echo /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330 `" ) && sleep 0'
Using module file /etc/ansible/library/rubrik_job_status.py
<LNXTEST2> PUT /home/ansible-deployer/.ansible/tmp/ansible-local-231295rgIPaM/tmpVEQFgs TO /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330/AnsiballZ_rubrik_job_status.py
<LNXTEST2> EXEC /bin/sh -c 'chmod u+x /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330/ /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330/AnsiballZ_rubrik_job_status.py && sleep 0'
<LNXTEST2> EXEC /bin/sh -c '/usr/bin/python /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330/AnsiballZ_rubrik_job_status.py && sleep 0'
<LNXTEST2> EXEC /bin/sh -c 'rm -f -r /home/ansible-deployer/.ansible/tmp/ansible-tmp-1558705566.5-201130080873330/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_rubrik_job_status_payload_Jl6Og8/__main__.py", line 105, in main
    api_request = rubrik.job_status(ansible["url"], ansible["wait_for_completion"], ansible["timeout"])
  File "/usr/lib/python2.7/site-packages/rubrik_cdm/api.py", line 292, in job_status
    timeout=timeout)
  File "/usr/lib/python2.7/site-packages/rubrik_cdm/api.py", line 72, in _common_api
    if '/cluster/me/bootstrap' in api_endpoint:

fatal: [LNXTEST2]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "node_ip": "XXX.XXX.XXX.XXX", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "provider": {
                "node_ip": "XXX.XXX.XXX.XXX", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "username": "ansible"
            }, 
            "timeout": 15, 
            "url": "https://XXX.XXX.XXX.XXX/api/internal/nutanix/vm/request/CREATE_NUTANIX_SNAPSHOT_1c38e8aa-3c96-48c0-8535-56f52c6b2b44-vm-ee080f60-e770-4edb-bf81-2c5634a47d3f_160a1493-b25b-4662-95f2-56f52c6b2b44:::0", 
            "username": "ansible", 
            "wait_for_completion": true
        }
    }, 
    "msg": "argument of type 'NoneType' is not iterable"
}

Steps to Reproduce

Context

drew-russell commented 5 years ago

This error is related to a bug in the Python SDK. I've created https://github.com/rubrikinc/rubrik-sdk-for-python/pull/96 to address the problem. Once the update has been reviewed and published, I will provide another update here.

drew-russell commented 5 years ago

@zisuu A new version of the Python SDK has been released that addresses this issue. Once updated, you shouldn't run into this.