2018-08-23 22:17:18 +08:00
|
|
|
---
|
|
|
|
- name: "Check vars defined correctly"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_pool_name is defined"
|
2018-10-18 03:27:11 +08:00
|
|
|
- "calico_pool_name is match('^[a-zA-Z0-9-_\\\\.]{2,63}$')"
|
2018-08-23 22:17:18 +08:00
|
|
|
- "ipip_mode is defined"
|
|
|
|
- "ipip_mode in ['Always', 'CrossSubnet', 'Never']"
|
|
|
|
msg: "Check variable definitions seems something is wrong"
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- name: "Get current version of calico cluster version"
|
2018-09-13 23:05:10 +08:00
|
|
|
shell: "{{ bin_dir }}/calicoctl version | grep 'Cluster Version:' | awk '{ print $3}'"
|
2018-08-23 22:17:18 +08:00
|
|
|
register: calico_version_on_server
|
|
|
|
run_once: yes
|
2019-02-26 12:09:30 +08:00
|
|
|
changed_when: false
|
2019-04-15 19:24:04 +08:00
|
|
|
environment:
|
|
|
|
ETCD_ENDPOINTS: "{{ etcd_access_addresses }}"
|
|
|
|
ETCD_CA_CERT_FILE: "{{ calico_cert_dir }}/ca_cert.crt"
|
|
|
|
ETCD_CERT_FILE: "{{ calico_cert_dir }}/cert.crt"
|
|
|
|
ETCD_KEY_FILE: "{{ calico_cert_dir }}/key.pem"
|
|
|
|
|
2018-08-23 22:17:18 +08:00
|
|
|
|
|
|
|
- name: "Determine if calico upgrade is needed"
|
|
|
|
block:
|
2018-09-23 21:33:17 +08:00
|
|
|
- name: "Check that calico version is enough for upgrade"
|
2018-08-23 22:17:18 +08:00
|
|
|
assert:
|
|
|
|
that:
|
2018-10-17 06:33:30 +08:00
|
|
|
- calico_version_on_server.stdout is version('v2.6.5', '>=')
|
2018-08-23 22:17:18 +08:00
|
|
|
msg: "Your version of calico is not fresh enough for upgrade"
|
2018-09-11 20:14:10 +08:00
|
|
|
when: calico_upgrade_enabled
|
2018-08-23 22:17:18 +08:00
|
|
|
|
|
|
|
- name: "Set upgrade flag when version needs to be updated"
|
|
|
|
set_fact:
|
|
|
|
calico_upgrade_needed: True
|
|
|
|
when:
|
2018-10-17 06:33:30 +08:00
|
|
|
- calico_version_on_server.stdout is version('v2.6.5', '>=')
|
|
|
|
- calico_version_on_server.stdout is version('v3.0.0', '<')
|
2018-08-23 22:17:18 +08:00
|
|
|
|
|
|
|
when:
|
2019-04-29 14:00:20 +08:00
|
|
|
- calico_version_on_server.stdout is defined
|
|
|
|
- calico_version_on_server.stdout
|
2018-08-23 22:17:18 +08:00
|
|
|
- inventory_hostname == groups['kube-master'][0]
|
2018-08-23 22:47:18 +08:00
|
|
|
run_once: yes
|