main.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ---
  2. - name: check user privilege
  3. include_role:
  4. name: utils/check-sudoer-privilege
  5. - name: ansible version
  6. set_fact:
  7. supported_ansible_version: "2.11.12"
  8. minimal_mem: "{{ 1 if lookup('env','IGNORE_ALL_CHECKS') == 'true' or enable_lbagent else 6 }}"
  9. minimal_cpu: "{{ 1 if lookup('env','IGNORE_ALL_CHECKS') == 'true' or enable_lbagent else 4 }}"
  10. - name: debug
  11. debug:
  12. msg: "minimal_mem: {{minimal_mem}} minimal_cpu: {{minimal_cpu}}"
  13. - block:
  14. - name: test ansible version expecting {{ supported_ansible_version }}, got {{ ansible_version.full }}
  15. fail:
  16. msg: "Expected ansible version: {{supported_ansible_version}}. Current ansible version is {{ ansible_version.full }}. Please uninstall the old ansible `yum remove -y ansible` or `pip uninstall ansible`, and install the latest ansible as root: `yum install -y python3-pip; python3 -m pip install --upgrade pip setuptools wheel; python3 -m pip install --upgrade ansible`"
  17. - meta: end_play
  18. when: ansible_version.full is version(supported_ansible_version, '<')
  19. - block:
  20. - name: print hostname msg
  21. fail:
  22. msg: "Host name can not contain 'localhost'!"
  23. - meta: end_play
  24. when: ansible_hostname | regex_search('^localhost', ignorecase=True)
  25. - block:
  26. - name: set fact if ignore resource check
  27. set_fact:
  28. ignore_check: "{{ lookup('env', 'IGNORE_ALL_CHECKS') | default('false') | lower}}"
  29. - name: Check Minimum Hardware Requirements
  30. assert:
  31. that:
  32. - ansible_processor_vcpus >= minimal_cpu | int
  33. - (ansible_memtotal_mb / 1024 +0.5) | round(1) | int >= minimal_mem | int
  34. msg: |
  35. cpu: got {{ ansible_processor_vcpus }} (req: {{minimal_cpu}} cores)
  36. mem: got {{(ansible_memtotal_mb / 1024 +0.5) | round(1) | int}}GB (req: {{minimal_mem}}GB)
  37. you may export IGNORE_ALL_CHECKS=true in test environment to ignore resource check.
  38. when:
  39. - ignore_check != True
  40. - name: check if os/ver is supported
  41. include_tasks: os.yml
  42. - name: Get SELinux status
  43. shell: |
  44. setenforce 0
  45. getenforce
  46. become: yes
  47. register: selinux_status
  48. failed_when: false
  49. args:
  50. executable: /bin/bash
  51. - name: Warning for SELinux
  52. fail:
  53. msg: "Please disable selinux and reboot the OS before deploying centos. "
  54. when:
  55. - selinux_status.stdout == 'Enforcing'