Bug 1753890

Summary: NSX ansible role templates refer to wrong variable to refer clusterip
Product: OpenShift Container Platform Reporter: Ravi Trivedi <travi>
Component: InstallerAssignee: Russell Teague <rteague>
Installer sub component: openshift-ansible QA Contact: Johnny Liu <jialiu>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: calfonso
Version: 3.11.0   
Target Milestone: ---   
Target Release: 3.11.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: NSX role templates referenced module output based on previous data structure. Consequence: Templates were not properly populated. Fix: Updated templates to use updated data structure. Result: Templates generated with clusterip as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-18 01:34:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ravi Trivedi 2019-09-20 07:40:07 UTC
Description of problem:

Version-Release number of the following components:
openshift-ansible 3.11.135/141
ansible 2.6.19

How reproducible:
Always

Steps to Reproduce:
1. Run role /usr/share/ansible/openshift-ansible/roles/nsx
2. Playbook would fail with error:

"nsx_k8s_svc.results.clusterip": "VARIABLE IS NOT DEFINED!: 'dict object' has no attribute 'results'"

Expected results:

Right variable to be used to resolve the clusterip.

Additional info:

EXPECTED OUTPUT:

TASK [NSX | Get kubernetes service] **********************************************************************************************************************************************************
ok: [localhost] => {"changed": false, "module_results": {"clusterip": "172.30.0.1", "cmd": "/bin/oc get service kubernetes -o json -n default", "results": [{"apiVersion": "v1", "kind": "Service", "metadata": {"creationTimestamp": "2019-09-17T09:46:31Z", "labels": {"component": "apiserver", "provider": "kubernetes"}, "name": "kubernetes", "namespace": "default", "resourceVersion": "54", "selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "070c168a-d930-11e9-8ca4-fa163eafa5c6"}, "spec": {"clusterIP": "172.30.0.1", "ports": [{"name": "https", "port": 443, "protocol": "TCP", "targetPort": 443}, {"name": "dns", "port": 53, "protocol": "UDP", "targetPort": 8053}, {"name": "dns-tcp", "port": 53, "protocol": "TCP", "targetPort": 8053}], "sessionAffinity": "None", "type": "ClusterIP"}, "status": {"loadBalancer": {}}}], "returncode": 0}, "state": "list"}                                                                             

TASK [debug] *********************************************************************************************************************************************************************************
ok: [localhost] => {
    "nsx_k8s_svc.module_results.clusterip": "172.30.0.1"
}

BUGGY OUTPUT:

PLAY [Check for the return value of NSX] *****************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [NSX | Get kubernetes service] **********************************************************************************************************************************************************
ok: [localhost] => {"changed": false, "module_results": {"clusterip": "172.30.0.1", "cmd": "/bin/oc get service kubernetes -o json -n default", "results": [{"apiVersion": "v1", "kind": "Service", "metadata": {"creationTimestamp": "2019-09-17T09:46:31Z", "labels": {"component": "apiserver", "provider": "kubernetes"}, "name": "kubernetes", "namespace": "default", "resourceVersion": "54", "selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "070c168a-d930-11e9-8ca4-fa163eafa5c6"}, "spec": {"clusterIP": "172.30.0.1", "ports": [{"name": "https", "port": 443, "protocol": "TCP", "targetPort": 443}, {"name": "dns", "port": 53, "protocol": "UDP", "targetPort": 8053}, {"name": "dns-tcp", "port": 53, "protocol": "TCP", "targetPort": 8053}], "sessionAffinity": "None", "type": "ClusterIP"}, "status": {"loadBalancer": {}}}], "returncode": 0}, "state": "list"}                                                                             

TASK [debug] *********************************************************************************************************************************************************************************
ok: [localhost] => {
    "nsx_k8s_svc.results.clusterip": "VARIABLE IS NOT DEFINED!: 'dict object' has no attribute 'results'"
}

PLAY RECAP ***********************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

Comment 2 Johnny Liu 2019-10-09 05:42:44 UTC
Verified this bug with openshift-ansible-3.11.152-1.git.0.3e13655.el7.noarch, and PASS.



TASK [nsx : NSX | Get kubernetes service] ****************************************************************************************************************************
task path: /usr/share/ansible/openshift-ansible/roles/nsx/tasks/main.yml:30
ok: [ci-vm-10-0-151-82.hosted.upshift.rdu2.redhat.com] => {"changed": false, "module_results": {"clusterip": "172.30.0.1", "cmd": "/usr/bin/oc get service kubernetes -o json -n default", "results": [{"apiVersion": "v1", "kind": "Service", "metadata": {"creationTimestamp": "2019-10-08T10:30:15Z", "labels": {"component": "apiserver", "provider": "kubernetes"}, "name": "kubernetes", "namespace": "default", "resourceVersion": "15", "selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "9dd5d453-e9b6-11e9-bbea-fa163e8c67f7"}, "spec": {"clusterIP": "172.30.0.1", "ports": [{"name": "https", "port": 443, "protocol": "TCP", "targetPort": 8443}, {"name": "dns", "port": 53, "protocol": "UDP", "targetPort": 8053}, {"name": "dns-tcp", "port": 53, "protocol": "TCP", "targetPort": 8053}], "sessionAffinity": "ClientIP", "sessionAffinityConfig": {"clientIP": {"timeoutSeconds": 10800}}, "type": "ClusterIP"}, "status": {"loadBalancer": {}}}], "returncode": 0}, "state": "list"}

TASK [nsx : NSX | Write NSX templates to nsx-ujo directory] **********************************************************************************************************
task path: /usr/share/ansible/openshift-ansible/roles/nsx/tasks/main.yml:38
changed: [ci-vm-10-0-151-82.hosted.upshift.rdu2.redhat.com] => (item={u'dest': u'ncp-configmap.yml', u'src': u'ncp-configmap.yml.j2'}) => {"changed": true, "checksum": "e62dcc7dacf0128ae6061ac2e17945c75fe7c1eb", "dest": "/etc/nsx-ujo/ncp-configmap.yml", "gid": 0, "group": "root", "item": {"dest": "ncp-configmap.yml", "src": "ncp-configmap.yml.j2"}, "md5sum": "2063363e88d52651be30c81d61efe5f0", "mode": "0555", "owner": "root", "secontext": "system_u:object_r:etc_t:s0", "size": 9991, "src": "/root/.ansible/tmp/ansible-tmp-1570598796.06-117262268389626/source", "state": "file", "uid": 0}
changed: [ci-vm-10-0-151-82.hosted.upshift.rdu2.redhat.com] => (item={u'dest': u'nsx-node-agent-configmap.yml', u'src': u'nsx-node-agent-configmap.yml.j2'}) => {"changed": true, "checksum": "8e0cce172f50db3d96438c5faa5bbcb6319180c8", "dest": "/etc/nsx-ujo/nsx-node-agent-configmap.yml", "gid": 0, "group": "root", "item": {"dest": "nsx-node-agent-configmap.yml", "src": "nsx-node-agent-configmap.yml.j2"}, "md5sum": "364d4c112598d33c4af3cfd85d5c95c4", "mode": "0555", "owner": "root", "secontext": "system_u:object_r:etc_t:s0", "size": 4777, "src": "/root/.ansible/tmp/ansible-tmp-1570598796.87-138153437154834/source", "state": "file", "uid": 0}
ok: [ci-vm-10-0-151-82.hosted.upshift.rdu2.redhat.com] => (item={u'dest': u'nsx-node-agent-ds.yml', u'src': u'nsx-node-agent-ds.yml.j2'}) => {"changed": false, "checksum": "27e0870576e887708786e18a517fe0a7b2f4d00d", "dest": "/etc/nsx-ujo/nsx-node-agent-ds.yml", "gid": 0, "group": "root", "item": {"dest": "nsx-node-agent-ds.yml", "src": "nsx-node-agent-ds.yml.j2"}, "mode": "0555", "owner": "root", "path": "/etc/nsx-ujo/nsx-node-agent-ds.yml", "secontext": "system_u:object_r:etc_t:s0", "size": 3197, "state": "file", "uid": 0}
ok: [ci-vm-10-0-151-82.hosted.upshift.rdu2.redhat.com] => (item={u'dest': u'ncp-rc.yml', u'src': u'ncp-rc.yml.j2'}) => {"changed": false, "checksum": "35845391807dd30baa249809cd0d486962f9759f", "dest": "/etc/nsx-ujo/ncp-rc.yml", "gid": 0, "group": "root", "item": {"dest": "ncp-rc.yml", "src": "ncp-rc.yml.j2"}, "mode": "0555", "owner": "root", "path": "/etc/nsx-ujo/ncp-rc.yml", "secontext": "system_u:object_r:etc_t:s0", "size": 1620, "state": "file", "uid": 0}



[root@qe-jialiu310master-etcd-nfs-1 ~]# cat /etc/nsx-ujo/ncp-configmap.yml|grep apiserver_host_ip
    apiserver_host_ip = "172.30.0.1"
[root@qe-jialiu310master-etcd-nfs-1 ~]# cat /etc/nsx-ujo/nsx-node-agent-configmap.yml|grep apiserver_host_ip
    #apiserver_host_ip = <ip_address>
    apiserver_host_ip = "172.30.0.1"

Comment 4 errata-xmlrpc 2019-10-18 01:34:37 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, 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/RHBA-2019:3139