From 611038e306bf9c98fa28f0d518ba445562b36ca4 Mon Sep 17 00:00:00 2001 From: Aleksandr Didenko Date: Wed, 7 Dec 2016 12:13:12 +0100 Subject: [PATCH] Fix possible problems with legacy calicoctl When running legacy calicoctl we do not specify calico hostname in calico-node container thus we should not specify it in CNI config. Also move 'legacy_calicoctl' set_fact task to the top. --- roles/network_plugin/calico/tasks/main.yml | 10 +++++----- .../network_plugin/calico/templates/cni-calico.conf.j2 | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/roles/network_plugin/calico/tasks/main.yml b/roles/network_plugin/calico/tasks/main.yml index 06c95eb56..4fd0bb999 100644 --- a/roles/network_plugin/calico/tasks/main.yml +++ b/roles/network_plugin/calico/tasks/main.yml @@ -1,4 +1,9 @@ --- +- name: Calico | Check calicoctl version + run_once: true + set_fact: + legacy_calicoctl: "{{ calicoctl_image_tag | version_compare('v1.0.0', '<') }}" + - name: Calico | Write Calico cni config template: src: "cni-calico.conf.j2" @@ -70,11 +75,6 @@ delegate_to: "{{groups['etcd'][0]}}" run_once: true -- name: Calico | Check calicoctl version - run_once: true - set_fact: - legacy_calicoctl: "{{ calicoctl_image_tag | version_compare('v1.0.0', '<') }}" - - name: Calico | Configure calico network pool shell: > echo '{ diff --git a/roles/network_plugin/calico/templates/cni-calico.conf.j2 b/roles/network_plugin/calico/templates/cni-calico.conf.j2 index 84e8ed447..8a3016324 100644 --- a/roles/network_plugin/calico/templates/cni-calico.conf.j2 +++ b/roles/network_plugin/calico/templates/cni-calico.conf.j2 @@ -1,6 +1,8 @@ { "name": "calico-k8s-network", +{% if not legacy_calicoctl %} "hostname": "{{ inventory_hostname }}", +{% endif %} "type": "calico", "etcd_endpoints": "{{ etcd_access_endpoint }}", "etcd_cert_file": "{{ etcd_cert_dir }}/node.pem",