Bug 1899609 - The conditional check 'inventory_hostname in groups['oo_masters']' failed.
Summary: The conditional check 'inventory_hostname in groups['oo_masters']' failed.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Installer
Version: 3.11.0
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.11.z
Assignee: Russell Teague
QA Contact: Gaoyun Pei
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-19 16:45 UTC by Andy Bartlett
Modified: 2024-03-25 17:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-12-16 12:35:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift openshift-ansible pull 12270 0 None closed playbooks/init: Fix GCP job when oo_masters is not defined 2021-01-26 23:44:04 UTC
Red Hat Product Errata RHSA-2020:5363 0 None None None 2020-12-16 12:35:50 UTC

Description Andy Bartlett 2020-11-19 16:45:02 UTC
Description of problem:

My Customer is reporting the following:

"we don't always have an oo_master group when we are running the plays, playbooks/init/cluster_facts.yml shouldn't error out."

We suspect the new 'Gather master facts'  task  should have a check for the existence of the oo_masters group. 

https://github.com/openshift/openshift-ansible/compare/openshift-ansible-3.11.317-1...openshift-ansible-3.11.318-1#diff-f7299f83c4344765f127597a90ab3ddcbcd76b9bbbaf9ce095cc1644d4f01d0a

Without it I get this error when building a base image for a node : 

[0;32m    amazon-ebs: fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"msg": "The conditional check 'inventory_hostname in groups['oo_masters']' failed. The error was: error while evaluating conditional (inventory_hostname in groups['oo_masters']): Unable to look up a name or access an attribute in template string ({% if inventory_hostname in groups['oo_masters'] %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'AnsibleUndefined' is not iterable\n\nThe error appears to be in '/home/jenkins_slave/openshift-ansible/playbooks/init/cluster_facts.yml': line 42, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Gather Master facts\n    ^ here\n"}[0m

There's a step earlier in the same play that looks like it checks if a group exists at all, Gather Master facts maybe needs a when condition like this one? 

  # oo_first_master group might not be present due to provisioning plays
  # for existing clusters, openshift_portal_net will be force-set by
  # basic_facts.yml from value in existing master configs.
  - name: set_fact openshift_portal_net if present on masters
    set_fact:
      openshift_portal_net: "{{ hostvars[groups.oo_first_master.0].openshift_portal_net }}"
    when:
    - "'oo_first_master' in groups"
    - "groups.oo_first_master | length > 0"
    - "'openshift_portal_net' in hostvars[groups.oo_first_master.0]"


Version-Release number of selected component (if applicable):
OCP 3.11.318

How reproducible:
100%

Steps to Reproduce:
1.
2.
3.

Actual results:

The play errors with:

[0;32m    amazon-ebs: fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"msg": "The conditional check 'inventory_hostname in groups['oo_masters']' failed. The error was: error while evaluating conditional (inventory_hostname in groups['oo_masters']): Unable to look up a name or access an attribute in template string ({% if inventory_hostname in groups['oo_masters'] %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'AnsibleUndefined' is not iterable\n\nThe error appears to be in '/home/jenkins_slave/openshift-ansible/playbooks/init/cluster_facts.yml': line 42, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Gather Master facts\n    ^ here\n"}[0m

Expected results:
Complete without errors


Additional info:

Comment 1 Ronnie Lazar 2020-11-22 09:11:21 UTC
andbartl This is not related to the Assisted-Installer component, and I'm not sure to what component it should be moved.

Comment 6 Russell Teague 2020-11-23 14:50:15 UTC
Any time the openshift-ansible playbooks are run, the inventory should be an accurate representation of the cluster being built.  That aside, there have been use cases built over the years where that is not always the case but things still worked.

This particular issue has already been fixed because it was identified in a CI job that also runs installer components out of order.

https://github.com/openshift/openshift-ansible/pull/12270

In build: openshift-ansible-3.11.319-1

Comment 7 Gaoyun Pei 2020-11-24 03:52:05 UTC
Verified this bug with openshift-ansible-3.11.321-1.git.0.a6d3b1c.el7.noarch.rpm.
Fresh install completed successfully, no regression issue found.

Comment 11 errata-xmlrpc 2020-12-16 12:35:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 3.11.343 security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:5363


Note You need to log in before you can comment on or make changes to this bug.