OpenStack - Kolla-Ansible prechecks error "Hostname has to resolve to IP address of api_interface"

Following the OpenStack Kolla Ansible documentation I was trying to check my kolla ansible environment by running this command:

sudo kolla-ansible prechecks

And I got this error:

TASK [rabbitmq : fail] ***************************************************************************************************************************************fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'item.stdout.find(hostvars[item['item']]['ansible_' ~ hostvars[item['item']]['api_interface']]['ipv4']['address']) == -1' failed. The error was: error while evaluating conditional (item.stdout.find(hostvars[item['item']]['ansible_' ~ hostvars[item['item']]['api_interface']]['ipv4']['address']) == -1): 'dict object' has no attribute 'api_interface'\n\nThe error appears to have been in '/usr/local/share/kolla-ansible/ansible/roles/rabbitmq/tasks/precheck.yml': line 59, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- fail: msg=\"Hostname has to resolve to IP address of api_interface\"\n  ^ here\n"}

At first, I tried to use the stable branch of kolla-ansible. stable/pike :

git clone -b stable/pike

However, the error was still persist after that. So I look at the failing task in the ansible playbook at /usr/local/share/kolla-ansible/ansible/roles/rabbitmq/tasks/precheck.yml:

- fail: msg="Hostname has to resolve to IP address of api_interface"
  with_items: "{{ rabbitmq_hostnames.results }}"
    - "item.stdout.find(hostvars[item['item']]['ansible_' ~ hostvars[item['item']]['api_interface']]['ipv4']['address']) == -1"

And I looked closer at the error message, aha, the task couldn't read the api_interface variable. So I went to the /etc/kolla/globals.yml and uncomment the api_interface line:

api_interface: "{{ network_interface }}"

Finally, the prechecks task was successful and I can deploy my stack.

This must be a bug of kolla ansible precheck task because the api_interface variable should get its default value if I don't modify it. I reported the bug here.