getting "Error in getting the server list: list index out of range" in nova_compute module

Hi All,

I’m new in Ansible and looking at the OpenStack related modules in ansible. All the modules worked pretty well in my environment except the nova_compute module when I tried to create a VM instance. I was getting the following error:

PLAY [all] ********************************************************************
TASK: [create vm] *************************************************************
failed: [172.17.252.66] => {“failed”: true}
msg: Error in getting the server list: list index out of range
FATAL: all hosts have already failed – aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/yuling_nova_compute.retry
172.17.252.66 : ok=0 changed=0 unreachable=0 failed=1

I was running an ansible playbook as follows:
[root@localhost test]# ansible-playbook -i hosts yuling_nova_compute.yml

Here is the playbook script:

I doubt a log file will give you any additional information.

I looked at nova_compute, and that error seems to occur in a specific situation.

The code does the following:

  1. List all servers, passing a filter parameter to the API where it filters based on the name you provided.
  2. If it get’s a list of servers back, it iterates through them, validating the name match
  3. It attempts to grab element 0 of the list of servers with that name match

In your case, it would appear the API is returning matches for ‘vm2’, but then on further inspection, there are no name matches.

Due to this “discrepancy” the module aborts.

If you use ‘novaclient’ you should be able to test the name matching, by performing a list such as:

nova list --name vm2

I’m guessing what you find is that you have another server with a name that starts or contains ‘vm2’ but doesn’t exactly match vm2 such as vm22 or such.

In which case, you may want to look at giving your new server the name “vm02” or similar.

Thanks very much Matt! What you described was exactly what the situation was and your suggestion solved my problem!

Yes, I did have one vm called ‘testvm2’ already existed in my environment. I guess this vm was the culprit. Now I used a different name ‘smallvm’, and the vm creation was successful.

Thanks again!

-YuLing