You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.2 KiB

  1. ---
  2. - name: "Check vars defined correctly"
  3. assert:
  4. that:
  5. - "calico_pool_name is defined"
  6. - "calico_pool_name is match('^[a-zA-Z0-9-_\\\\.]{2,63}$')"
  7. msg: "calico_pool_name contains invalid characters"
  8. - name: "Check calico network backend defined correctly"
  9. assert:
  10. that:
  11. - "calico_network_backend in ['bird', 'vxlan', 'none']"
  12. msg: "calico network backend is not 'bird', 'vxlan' or 'none'"
  13. when:
  14. - calico_network_backend is defined
  15. - name: "Check ipip and vxlan mode defined correctly"
  16. assert:
  17. that:
  18. - "calico_ipip_mode in ['Always', 'CrossSubnet', 'Never']"
  19. - "calico_vxlan_mode in ['Always', 'CrossSubnet', 'Never']"
  20. msg: "calico inter host encapsulation mode is not 'Always', 'CrossSubnet' or 'Never'"
  21. - name: "Check ipip and vxlan mode if simultaneously enabled"
  22. assert:
  23. that:
  24. - "calico_vxlan_mode in ['Never']"
  25. msg: "IP in IP and VXLAN mode is mutualy exclusive modes"
  26. when:
  27. - "calico_ipip_mode in ['Always', 'CrossSubnet']"
  28. - name: "Check ipip and vxlan mode if simultaneously enabled"
  29. assert:
  30. that:
  31. - "calico_ipip_mode in ['Never']"
  32. msg: "IP in IP and VXLAN mode is mutualy exclusive modes"
  33. when:
  34. - "calico_vxlan_mode in ['Always', 'CrossSubnet']"
  35. - name: "Get Calico {{ calico_pool_name }} configuration"
  36. command: calicoctl.sh get ipPool {{ calico_pool_name }} -o json
  37. failed_when: False
  38. changed_when: False
  39. register: calico
  40. run_once: True
  41. delegate_to: "{{ groups['kube_control_plane'][0] }}"
  42. - name: "Set calico_pool_conf"
  43. set_fact:
  44. calico_pool_conf: '{{ calico.stdout | from_json }}'
  45. when: calico.rc == 0 and calico.stdout
  46. - name: "Check if inventory match current cluster configuration"
  47. assert:
  48. that:
  49. - calico_pool_conf.spec.blockSize == (calico_pool_blocksize | default(kube_network_node_prefix))
  50. - calico_pool_conf.spec.cidr == (calico_pool_cidr | default(kube_pods_subnet))
  51. - not calico_pool_conf.spec.ipipMode is defined or calico_pool_conf.spec.ipipMode == calico_ipip_mode
  52. - not calico_pool_conf.spec.vxlanMode is defined or calico_pool_conf.spec.vxlanMode == calico_vxlan_mode
  53. msg: "Your inventory doesn't match the current cluster configuration"
  54. when:
  55. - calico_pool_conf is defined