Browse Source

refactor to base on calico_version

pull/3284/head
Matthew Mosesohn 6 years ago
parent
commit
c83350e597
2 changed files with 11 additions and 14 deletions
  1. 2
      roles/network_plugin/calico/tasks/check.yml
  2. 23
      roles/network_plugin/calico/tasks/install.yml

2
roles/network_plugin/calico/tasks/check.yml

@ -10,7 +10,7 @@
run_once: yes run_once: yes
- name: "Get current version of calico cluster version" - 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 register: calico_version_on_server
run_once: yes run_once: yes
delegate_to: "{{ groups['kube-master'][0] }}" delegate_to: "{{ groups['kube-master'][0] }}"

23
roles/network_plugin/calico/tasks/install.yml

@ -101,8 +101,8 @@
run_once: true run_once: true
delegate_to: "{{ groups['kube-master'][0] }}" delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_upgrade_enabled or calico_version_on_server.stdout|version_compare('v3.0.0', '>')
- 'calico_conf.stdout == "0"' - 'calico_conf.stdout == "0"'
- calico_version | version_compare("v3.0.0", ">=")
- name: Calico | Configure calico network pool (legacy) - name: Calico | Configure calico network pool (legacy)
shell: > shell: >
@ -118,9 +118,8 @@
run_once: true run_once: true
delegate_to: "{{ groups['kube-master'][0] }}" delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '<')
- not calico_upgrade_enabled
- 'calico_conf.stdout == "0"' - 'calico_conf.stdout == "0"'
- calico_version | version_compare("v3.0.0", "<")
- name: "Determine nodeToNodeMesh needed state" - name: "Determine nodeToNodeMesh needed state"
set_fact: set_fact:
@ -145,20 +144,19 @@
run_once: true run_once: true
delegate_to: "{{ groups['kube-master'][0] }}" delegate_to: "{{ groups['kube-master'][0] }}"
when: 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) - name: Calico | Set global as_num (legacy)
command: "{{ bin_dir}}/calicoctl config set asNumber {{ global_as_num }}" command: "{{ bin_dir}}/calicoctl config set asNumber {{ global_as_num }}"
run_once: true run_once: true
when: 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) - name: Calico | Disable node mesh (legacy)
command: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off" command: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off"
run_once: yes run_once: yes
when: 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) - nodeToMeshEnabled|default(True)
- name: Calico | Configure peering with router(s) - name: Calico | Configure peering with router(s)
@ -180,7 +178,7 @@
with_items: with_items:
- "{{ peers|default([]) }}" - "{{ peers|default([]) }}"
when: 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) - peer_with_router|default(false)
- inventory_hostname in groups['k8s-cluster'] - inventory_hostname in groups['k8s-cluster']
@ -197,8 +195,7 @@
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ peers|default([]) }}" with_items: "{{ peers|default([]) }}"
when: 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) - peer_with_router|default(false)
- inventory_hostname in groups['k8s-cluster'] - inventory_hostname in groups['k8s-cluster']
@ -221,7 +218,7 @@
with_items: with_items:
- "{{ groups['calico-rr'] | default([]) }}" - "{{ groups['calico-rr'] | default([]) }}"
when: 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) - peer_with_calico_rr|default(false)
- inventory_hostname in groups['k8s-cluster'] - inventory_hostname in groups['k8s-cluster']
- hostvars[item]['cluster_id'] == cluster_id - hostvars[item]['cluster_id'] == cluster_id
@ -241,7 +238,7 @@
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ groups['calico-rr'] | default([]) }}" with_items: "{{ groups['calico-rr'] | default([]) }}"
when: when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '<')
- calico_version | version_compare('v3.0.0', '<')
- not calico_upgrade_enabled - not calico_upgrade_enabled
- peer_with_calico_rr|default(false) - peer_with_calico_rr|default(false)
- hostvars[item]['cluster_id'] == cluster_id - hostvars[item]['cluster_id'] == cluster_id

Loading…
Cancel
Save