From c83350e59709df4e3200b37d462d5ad16e9d670c Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Thu, 13 Sep 2018 18:05:10 +0300 Subject: [PATCH] refactor to base on calico_version --- roles/network_plugin/calico/tasks/check.yml | 2 +- roles/network_plugin/calico/tasks/install.yml | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/roles/network_plugin/calico/tasks/check.yml b/roles/network_plugin/calico/tasks/check.yml index 89f204c59..7ddca6418 100644 --- a/roles/network_plugin/calico/tasks/check.yml +++ b/roles/network_plugin/calico/tasks/check.yml @@ -10,7 +10,7 @@ run_once: yes - name: "Get current version of calico cluster version" - shell: "{{ bin_dir }}/calicoctl version | grep 'Cluster Version' | awk '{ print $3}'" + shell: "{{ bin_dir }}/calicoctl version | grep 'Cluster Version:' | awk '{ print $3}'" register: calico_version_on_server run_once: yes delegate_to: "{{ groups['kube-master'][0] }}" diff --git a/roles/network_plugin/calico/tasks/install.yml b/roles/network_plugin/calico/tasks/install.yml index 294b09d3b..f2d41f9fc 100644 --- a/roles/network_plugin/calico/tasks/install.yml +++ b/roles/network_plugin/calico/tasks/install.yml @@ -101,8 +101,8 @@ run_once: true delegate_to: "{{ groups['kube-master'][0] }}" when: - - calico_upgrade_enabled or calico_version_on_server.stdout|version_compare('v3.0.0', '>') - 'calico_conf.stdout == "0"' + - calico_version | version_compare("v3.0.0", ">=") - name: Calico | Configure calico network pool (legacy) shell: > @@ -118,9 +118,8 @@ run_once: true delegate_to: "{{ groups['kube-master'][0] }}" when: - - calico_version_on_server.stdout|version_compare('v3.0.0', '<') - - not calico_upgrade_enabled - 'calico_conf.stdout == "0"' + - calico_version | version_compare("v3.0.0", "<") - name: "Determine nodeToNodeMesh needed state" set_fact: @@ -145,20 +144,19 @@ run_once: true delegate_to: "{{ groups['kube-master'][0] }}" when: - - calico_upgrade_enabled or calico_version_on_server.stdout|version_compare('v3.0.0', '>') + - calico_version | version_compare('v3.0.0', '>=') + - name: Calico | Set global as_num (legacy) command: "{{ bin_dir}}/calicoctl config set asNumber {{ global_as_num }}" run_once: true when: - - calico_version_on_server.stdout|version_compare('v3.0.0', '<') - - not calico_upgrade_enabled + - calico_version | version_compare('v3.0.0', '<') - name: Calico | Disable node mesh (legacy) command: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off" run_once: yes when: - - calico_version_on_server.stdout|version_compare('v3.0.0', '<') - - not calico_upgrade_enabled + - calico_version | version_compare('v3.0.0', '<') - nodeToMeshEnabled|default(True) - name: Calico | Configure peering with router(s) @@ -180,7 +178,7 @@ with_items: - "{{ peers|default([]) }}" when: - - calico_upgrade_enabled or calico_version_on_server.stdout|version_compare('v3.0.0', '>') + - calico_version | version_compare('v3.0.0', '>=') - peer_with_router|default(false) - inventory_hostname in groups['k8s-cluster'] @@ -197,8 +195,7 @@ delay: "{{ retry_stagger | random + 3 }}" with_items: "{{ peers|default([]) }}" when: - - calico_version_on_server.stdout|version_compare('v3.0.0', '<') - - not calico_upgrade_enabled + - calico_version | version_compare('v3.0.0', '<') - peer_with_router|default(false) - inventory_hostname in groups['k8s-cluster'] @@ -221,7 +218,7 @@ with_items: - "{{ groups['calico-rr'] | default([]) }}" when: - - calico_upgrade_enabled or calico_version_on_server.stdout|version_compare('v3.0.0', '>') + - calico_version | version_compare('v3.0.0', '>=') - peer_with_calico_rr|default(false) - inventory_hostname in groups['k8s-cluster'] - hostvars[item]['cluster_id'] == cluster_id @@ -241,7 +238,7 @@ delay: "{{ retry_stagger | random + 3 }}" with_items: "{{ groups['calico-rr'] | default([]) }}" when: - - calico_version_on_server.stdout|version_compare('v3.0.0', '<') + - calico_version | version_compare('v3.0.0', '<') - not calico_upgrade_enabled - peer_with_calico_rr|default(false) - hostvars[item]['cluster_id'] == cluster_id