5 Essential Tips for Maximizing Your Experience at Nutanix .NEXT for Bloggers
Yes; I pulled the inventory straight from Nutanix and also double checked in Prism. It’s giving this status code (which I guess is really just a time out?) for specific VMs. I’m guessing there must be something wrong with how these VMs are configured.
So since there are some VMs it works for and some it doesn’t, I feel as though it must not be the syntax for the hostname? Just the same, I tried it the ways you suggested and still get the same ‘-1 status code’. Here’s the task in question, and what happens when it’s at that step: tasks: - name: query to get UUID uri: url: "{{ base_urlv3 }}/vms/list" validate_certs: no force_basic_auth: yes method: POST status_code: 200 user: "{{ username }}" password: "{{ password }}" return_content: yes body_format: json body: filter: "vm_name=={{ inventory_hostname }}" kind: "vm" sort_order: "ASCENDING" offset: 0 length: 1 sort_attribute: "" register: retvalq tags: query TASK [query to get UUID] *********************************************************************************************Tuesday 03 December 2019 08:12:22 -0500 (0:00:01.408) 0:00:01.496 ******ok: [testmachine01]ok: [testmachine02]fatal: [testmachine03]: FAILED! => {"changed": false, "content": "", "msg": "Status code was -1 and n
Not sure if this should go in this post or in another, but I can’t find any information on this error code… There’s a handful of VM’s that are timing out when I run the above playbook against them. This is the error code: fatal: [testvm1]: FAILED! => {"changed": false, "content": "", "msg": "Status code was -1 and not [200]: Request failed: <urlopen error timed out>", "redirected": false, "status": -1, "url": "https://vipcluster1.domain.com:9440/api/nutanix/v3/vms/list"} It seems about 50/50 whether the API call will return successfully or with that error code above. I’m trying to find obvious differences between the ones that work and the ones that don’t, but can’t see anything. Any ideas? Thanks!
Thanks for the responses everyone -- @CPatterson , that playbook is incredibly helpful. I was having a lot of trouble figuring out how to have Ansible parse the information being sent back by the API calls. I’d like to be able to run this against many machines at once, so instead of having it run locally or on the cluster, I run the playbook against a VM inventory and pass the VM name with the magic inventory variable: body: filter: "vm_name=={{ inventory_hostname }}" kind: "vm" sort_order: "ASCENDING" Unfortunately though I think I’ll still have to separate VM’s by OS initially; since the connection parameters are different for Windows and Linux. I haven’t yet found a way to enumerate guest OS with Nutanix API’s or powershell cmdlets. Thanks!
Hey Alona, I think I just got this script to work; however it seems like it returns what looks like json but is really just one giant string of all the VM’s on the cluster. I know this is really only my own limitations using Ansible; but I can’t figure out how to make sense of the output and have Ansible actually able to use it.
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.