From 8872b2e0c6eb02590a844b0e7d5f51b6c852ca78 Mon Sep 17 00:00:00 2001
From: Chad Swenson <chadswen@gmail.com>
Date: Wed, 13 Feb 2019 18:02:48 -0600
Subject: [PATCH] Fix calico when kube_override_hostname is set (#4235)

This fixes an issue where the `nodename` in calico's cni config json can fall out of sync with the k8s node name used by the calico pod if `kube_override_hostname` is set
---
 roles/network_plugin/calico/defaults/main.yml | 2 +-
 roles/network_plugin/calico/tasks/main.yml    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/roles/network_plugin/calico/defaults/main.yml b/roles/network_plugin/calico/defaults/main.yml
index f53394489..49672a584 100644
--- a/roles/network_plugin/calico/defaults/main.yml
+++ b/roles/network_plugin/calico/defaults/main.yml
@@ -61,7 +61,7 @@ calico_healthhost: "localhost"
 # see https://docs.projectcalico.org/v3.0/reference/node/configuration#ip-autodetection-methods
 # calico_ip_auto_method: "interface=eth.*"
 
-calico_baremetal_nodename: "{{ inventory_hostname }}"
+calico_baremetal_nodename: "{{ kube_override_hostname | default(inventory_hostname) }}"
 
 ### do not enable this, this is detected in scope of tasks, this is just a default value
 calico_upgrade_needed: false
diff --git a/roles/network_plugin/calico/tasks/main.yml b/roles/network_plugin/calico/tasks/main.yml
index 07f92dac5..881c2eb5f 100644
--- a/roles/network_plugin/calico/tasks/main.yml
+++ b/roles/network_plugin/calico/tasks/main.yml
@@ -1,7 +1,7 @@
 ---
-- include_tasks: check.yml
+- import_tasks: check.yml
 
-- include_tasks: pre.yml
+- import_tasks: pre.yml
 
 - import_tasks: upgrade.yml
   when:
-- 
GitLab