From 128d3ef94cc3bffe21fdd3f5035064c71353fafc Mon Sep 17 00:00:00 2001
From: RongZhang <rong.zhang@easystack.cn>
Date: Tue, 27 Feb 2018 07:32:20 -0600
Subject: [PATCH] Fix run kubectl error (#2199)

* Fix run kubectl error

Fix run kubectl error when first master doesn't work

* if access_ip is define use first_kube_master
else different master use a different ip

* Delete set first_kube_master and use kube_apiserver_access_address
---
 roles/kubernetes/client/tasks/main.yml | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/roles/kubernetes/client/tasks/main.yml b/roles/kubernetes/client/tasks/main.yml
index e20a71eb8..3b66c5e1c 100644
--- a/roles/kubernetes/client/tasks/main.yml
+++ b/roles/kubernetes/client/tasks/main.yml
@@ -1,15 +1,11 @@
 ---
-- name: Set first kube master
-  set_fact:
-    first_kube_master: "{{ hostvars[groups['kube-master'][0]]['access_ip'] | default(hostvars[groups['kube-master'][0]]['ip'] | default(hostvars[groups['kube-master'][0]]['ansible_default_ipv4']['address'])) }}"
-
 - name: Set external kube-apiserver endpoint
   set_fact:
     external_apiserver_endpoint: >-
       {%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
       https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
       {%- else -%}
-      https://{{ first_kube_master }}:{{ kube_apiserver_port }}
+      https://{{ kube_apiserver_address }}:{{ kube_apiserver_port }}
       {%- endif -%}
   tags:
     - facts
-- 
GitLab