2018-08-23 14:17:18 +00:00
|
|
|
---
|
|
|
|
- name: "Check vars defined correctly"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_pool_name is defined"
|
2018-10-17 19:27:11 +00:00
|
|
|
- "calico_pool_name is match('^[a-zA-Z0-9-_\\\\.]{2,63}$')"
|
2020-03-12 08:20:37 +00:00
|
|
|
msg: "calico_pool_name contains invalid characters"
|
|
|
|
|
|
|
|
- name: "Check calico network backend defined correctly"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_network_backend in ['bird', 'vxlan', 'none']"
|
|
|
|
msg: "calico network backend is not 'bird', 'vxlan' or 'none'"
|
|
|
|
when:
|
|
|
|
- calico_network_backend is defined
|
|
|
|
|
|
|
|
- name: "Check ipip and vxlan mode defined correctly"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_ipip_mode in ['Always', 'CrossSubnet', 'Never']"
|
|
|
|
- "calico_vxlan_mode in ['Always', 'CrossSubnet', 'Never']"
|
|
|
|
msg: "calico inter host encapsulation mode is not 'Always', 'CrossSubnet' or 'Never'"
|
|
|
|
|
|
|
|
- name: "Check ipip and vxlan mode if simultaneously enabled"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_vxlan_mode in ['Never']"
|
|
|
|
msg: "IP in IP and VXLAN mode is mutualy exclusive modes"
|
|
|
|
when:
|
|
|
|
- "calico_ipip_mode in ['Always', 'CrossSubnet']"
|
|
|
|
|
|
|
|
- name: "Check ipip and vxlan mode if simultaneously enabled"
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "calico_ipip_mode in ['Never']"
|
|
|
|
msg: "IP in IP and VXLAN mode is mutualy exclusive modes"
|
|
|
|
when:
|
|
|
|
- "calico_vxlan_mode in ['Always', 'CrossSubnet']"
|
2021-01-04 17:07:56 +00:00
|
|
|
|
|
|
|
- name: "Get Calico {{ calico_pool_name }} configuration"
|
|
|
|
command: calicoctl.sh get ipPool {{ calico_pool_name }} -o json
|
|
|
|
failed_when: False
|
|
|
|
changed_when: False
|
|
|
|
register: calico
|
|
|
|
run_once: True
|
2021-03-24 00:26:05 +00:00
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
2021-01-04 17:07:56 +00:00
|
|
|
|
|
|
|
- name: "Set calico_pool_conf"
|
|
|
|
set_fact:
|
|
|
|
calico_pool_conf: '{{ calico.stdout | from_json }}'
|
|
|
|
when: calico.rc == 0 and calico.stdout
|
|
|
|
|
|
|
|
- name: "Check if inventory match current cluster configuration"
|
|
|
|
assert:
|
|
|
|
that:
|
2021-10-24 18:42:21 +00:00
|
|
|
- calico_pool_conf.spec.blockSize|string == (calico_pool_blocksize | default(kube_network_node_prefix | string))
|
2021-01-04 17:07:56 +00:00
|
|
|
- calico_pool_conf.spec.cidr == (calico_pool_cidr | default(kube_pods_subnet))
|
2021-01-22 04:39:26 +00:00
|
|
|
- not calico_pool_conf.spec.ipipMode is defined or calico_pool_conf.spec.ipipMode == calico_ipip_mode
|
|
|
|
- not calico_pool_conf.spec.vxlanMode is defined or calico_pool_conf.spec.vxlanMode == calico_vxlan_mode
|
2021-01-04 17:07:56 +00:00
|
|
|
msg: "Your inventory doesn't match the current cluster configuration"
|
|
|
|
when:
|
|
|
|
- calico_pool_conf is defined
|