Skip to content
Snippets Groups Projects
0020-verify-settings.yml 8.43 KiB
---
- name: Stop if either kube-master, kube-node or etcd is empty
  assert:
    that: groups.get('{{ item }}')
  with_items:
    - kube-master
    - kube-node
    - etcd
  run_once: true
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if non systemd OS type
  assert:
    that: ansible_service_mgr == "systemd"
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if unknown OS
  assert:
    that: ansible_os_family in ['RedHat', 'CentOS', 'Fedora', 'Ubuntu', 'Debian', 'CoreOS', 'Container Linux by CoreOS', 'Suse', 'ClearLinux', 'OracleLinux']
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if unknown network plugin
  assert:
    that: kube_network_plugin in ['calico', 'canal', 'flannel', 'weave', 'cloud', 'cilium', 'cni', 'contiv', 'kube-router', 'macvlan']
  when: kube_network_plugin is defined
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if incompatible network plugin and cloudprovider
  assert:
    that: kube_network_plugin != 'calico'
    msg: "Azure and Calico are not compatible. See https://github.com/projectcalico/calicoctl/issues/949 for details."
  when: cloud_provider is defined and cloud_provider == 'azure'
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if unsupported version of Kubernetes
  assert:
    that: kube_version is version(kube_version_min_required, '>=')
    msg: "The current release of Kubespray only support newer vesion of Kubernetes than {{ kube_version_min_required }} - You are trying to apply {{ kube_version }}"
  ignore_errors: "{{ ignore_assert_errors }}"

# simplify this items-list when   https://github.com/ansible/ansible/issues/15753  is resolved
- name: "Stop if known booleans are set as strings (Use JSON format on CLI: -e \"{'key': true }\")"
  assert:
    that: item.value|type_debug == 'bool'
    msg: "{{ item.value }} isn't a bool"
  run_once: yes
  with_items:
    - { name: download_run_once, value: "{{ download_run_once }}" }
    - { name: deploy_netchecker, value: "{{ deploy_netchecker }}" }
    - { name: download_always_pull, value: "{{ download_always_pull }}" }
    - { name: helm_enabled, value: "{{ helm_enabled }}" }
    - { name: openstack_lbaas_enabled, value: "{{ openstack_lbaas_enabled }}" }
  ignore_errors: "{{ ignore_assert_errors }}"

- name: Stop if even number of etcd hosts
  assert:
    that: groups.etcd|length is not divisibleby 2
  ignore_errors: "{{ ignore_assert_errors }}"
  when: inventory_hostname in groups['etcd']

- name: Stop if memory is too small for masters
  assert:
    that: ansible_memtotal_mb >= minimal_master_memory_mb
  ignore_errors: "{{ ignore_assert_errors }}"
  when: inventory_hostname in groups['kube-master']

- name: Stop if memory is too small for nodes
  assert:
    that: ansible_memtotal_mb >= minimal_node_memory_mb
  ignore_errors: "{{ ignore_assert_errors }}"