refactor to base on calico_version

This commit is contained in:
Matthew Mosesohn 2018-09-13 18:05:10 +03:00
parent 55d76ea3d8
commit c83350e597
2 changed files with 11 additions and 14 deletions

View file

@ -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] }}"

View file

@ -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