Precheck's rabbitmq task will fail if not indicating api_interface in globals.yml

Bug #1727793 reported by Trinh Nguyen
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
kolla-ansible
In Progress
Undecided
Trinh Nguyen

Bug Description

When not indicating api_interface (you suppose to use its default value) in /etc/kolla/globals.yml:

api_interface: "{{ network_interface }}"

kolla-ansible's prechecks (/usr/local/share/kolla-ansible/ansible/roles/rabbitmq/tasks/precheck.yml) will fail at this step:

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

Solution: The task should check whether the variable is indicated first before comparing it with the hostname. If the variable does not exist (or commented out), use the default value.

+ Error:

TASK [rabbitmq : fail] ****************************************************************************************
skipping: [localhost] => (item={'_ansible_parsed': True, 'stderr_lines': [], u'cmd': [u'getent', u'ahostsv4', u'ubuntu'], u'end': u'2017-11-24 00:35:57.440438', '_ansible_no_log': False, u'stdout': u'192.168.2.123 STREAM ubuntu\n192.168.2.123 DGRAM \n192.168.2.123 RAW ', '_ansible_item_result': True, u'changed': False, 'item': u'localhost', u'delta': u'0:00:00.001882', u'stderr': u'', u'rc': 0, u'invocation': {u'module_args': {u'warn': True, u'executable': None, u'_uses_shell': False, u'_raw_params': u'getent ahostsv4 ubuntu', u'removes': None, u'creates': None, u'chdir': None, u'stdin': None}}, 'stdout_lines': [u'192.168.2.123 STREAM ubuntu', u'192.168.2.123 DGRAM ', u'192.168.2.123 RAW '], u'start': u'2017-11-24 00:35:57.438556', 'failed': False}) => {"changed": false, "item": {"changed": false, "cmd": ["getent", "ahostsv4", "ubuntu"], "delta": "0:00:00.001882", "end": "2017-11-24 00:35:57.440438", "failed": false, "invocation": {"module_args": {"_raw_params": "getent ahostsv4 ubuntu", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "warn": true}}, "item": "localhost", "rc": 0, "start": "2017-11-24 00:35:57.438556", "stderr": "", "stderr_lines": [], "stdout": "192.168.2.123 STREAM ubuntu\n192.168.2.123 DGRAM \n192.168.2.123 RAW ", "stdout_lines": ["192.168.2.123 STREAM ubuntu", "192.168.2.123 DGRAM ", "192.168.2.123 RAW "]}, "skip_reason": "Conditional result was False", "skipped": true}

+ host file:

cat /etc/hosts
"
127.0.1.1 localhost
127.0.0.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
"

Tags: prechecks
summary: - Precheck's rabbitmq task will fails if not indicating api_interface in
+ Precheck's rabbitmq task will fail if not indicating api_interface in
globals.yml
tags: added: deploy
tags: added: prechecks
removed: deploy
Revision history for this message
Eduardo Gonzalez (egonzalez90) wrote :

Hi, api_interface is defined in group_vars/all too. This means if you don't specify the var in globals will always use default value in group_vars.

I you comment value in globals should be working too.

https://github.com/openstack/kolla-ansible/blob/master/ansible/group_vars/all.yml#L132

I don't see a bug here.

Regards

Changed in kolla-ansible:
status: New → Incomplete
Revision history for this message
Eduardo Gonzalez (egonzalez90) wrote :

Marked as incomplete, please add more information to try understand your issue.

Regards

Revision history for this message
Trinh Nguyen (dangtrinhnt) wrote :

Hi,

Actually that's what I though it should be but It's not like you said. I left the variable uncommented by default and ran into this error.

Kolla-Ansible 5.0.1
Kolla 5.0.1
Ubuntu 16.04

Revision history for this message
Ravi Shekhar Jethani (ravishekar-jethani) wrote :

Kindly post full error that you are getting and try executing like:
kolla-ansible prechecks -vi <inventory file>

Also post what is in your /etc/hosts file

Revision history for this message
D Haas (uz6945) wrote :

dangtrinhnt (OP) has documented this on his blog
(http://www.dangtrinh.com/2017/10/openstack-kolla-ansible-prechecks-error.html)

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'

The error appears to have been in '/usr/local/share/kolla-ansible/ansible/roles/rabbitmq/tasks/precheck.yml': line 59, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:
- fail: msg="Hostname has to resolve to IP address of api_interface"
  ^ here "}

Revision history for this message
D Haas (uz6945) wrote :
Download full text (4.2 KiB)

Can reproduce this. With a fresh Ubuntu 16.04 /etc/hosts.

kolla-ansible prechecks -vi <inventory file>
does not yield more detail
(Only other warning I get is "[WARNING]: Found variable using reserved name: action")

cat /etc/hosts
"
127.0.1.1 localhost
127.0.0.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
"
... will produce the 'error while evaluating conditional' as described above.

But the check fails as intended, and more correctly, if
 api_interface: "{{ network_interface }}"
gets uncommented as described above.

TASK [rabbitmq : fail] ****************************************************************************************
failed: [localhost] (item={'_ansible_parsed': True, 'stderr_lines': [], u'cmd': [u'getent', u'ahostsv4', u'ubuntu'], u'end': u'2017-11-24 00:31:30.840236', '_ansible_no_log': False, u'stdout': u'127.0.0.1 STREAM ubuntu
127.0.0.1 DGRAM
127.0.0.1 RAW ', '_ansible_item_result': True, u'changed': False, 'item': u'localhost', u'delta': u'0:00:00.002361', u'stderr': u'', u'rc': 0, u'invocation': {u'module_args': {u'warn': True, u'executable': None, u'_uses_shell': False, u'_raw_params': u'getent ahostsv4 ubuntu', u'removes': None, u'creates': None, u'chdir': None, u'stdin': None}}, 'stdout_lines': [u'127.0.0.1 STREAM ubuntu', u'127.0.0.1 DGRAM ', u'127.0.0.1 RAW '], u'start': u'2017-11-24 00:31:30.837875', 'failed': False}) => {"changed": false, "failed": true, "item": {"changed": false, "cmd": ["getent", "ahostsv4", "ubuntu"], "delta": "0:00:00.002361", "end": "2017-11-24 00:31:30.840236", "failed": false, "invocation": {"module_args": {"_raw_params": "getent ahostsv4 ubuntu", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "warn": true}}, "item": "localhost", "rc": 0, "start": "2017-11-24 00:31:30.837875", "stderr": "", "stderr_lines": [], "stdout": "127.0.0.1 STREAM ubuntu
127.0.0.1 DGRAM
127.0.0.1 RAW ", "stdout_lines": ["127.0.0.1 STREAM ubuntu", "127.0.0.1 DGRAM ", "127.0.0.1 RAW "]}, "msg": "Hostname has to resolve to IP address of api_interface"}

Furthermore, the check succeeds (skipps) correctly, after fixing the prepared setup, and pointing the hostname towards the api_interface IP

root@ubuntu:/# cat /etc/hosts
192.168.2.123 ubuntu
127.0.1.1 localhost
#127.0.0.1 ubuntu
[...]

TASK [rabbitmq : fail] ****************************************************************************************
skipping: [localhost] => (item={'_ansible_parsed': True, 'stderr_lines': [], u'cmd': [u'getent', u'ahostsv4', u'ubuntu'], u'end': u'2017-11-24 00:35:57.440438', '_ansible_no_log': False, u'stdout': u'192.168.2.123 STREAM ubuntu\n192.168.2.123 DGRAM \n192.168.2.123 RAW ', '_ansible_item_result': True, u'changed': False, 'item': u'localhost', u'delta': u'0:00:00.001882', u'stderr': u'', u'rc': 0, u'invocation': {u'module_args': {u'warn': True, u'executable': None, u'_uses_shell': False, u'_raw_params': u'getent ahostsv4 ubuntu', u'removes': ...

Read more...

Revision history for this message
Alvaro Aleman (alvaroaleman) wrote :

Repro for centos 7.4 attached. Happens when following the doc at https://docs.openstack.org/kolla-kubernetes/latest/deployment-guide.html, Version: "UPDATED: 2017-11-20 17:38"

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for kolla-ansible because there has been no activity for 60 days.]

Changed in kolla-ansible:
status: Incomplete → Expired
Changed in kolla-ansible:
assignee: nobody → Trinh Nguyen (dangtrinhnt)
description: updated
Changed in kolla-ansible:
status: Expired → In Progress
Revision history for this message
Trinh Nguyen (dangtrinhnt) wrote :

Thanks D Haas (uz6945) and Alvaro Aleman (alvaroaleman) for reporting. I will work on a fix for this.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.