validate_provision_vars.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Convert timezone.txt to linux format
  16. command: dos2unix {{ role_path }}/files/timezone.txt
  17. failed_when: false
  18. changed_when: false
  19. - name: Searching for timezone
  20. lineinfile:
  21. path: "{{ role_path }}/files/timezone.txt"
  22. line: "{{ timezone }}"
  23. state: present
  24. check_mode: yes
  25. register: timezone_search
  26. - name: Assert timezone
  27. assert:
  28. that: timezone_search is not changed
  29. success_msg: "{{ success_timezone_msg }}"
  30. fail_msg: "{{ fail_timezone_msg }}"
  31. register: timezone_check
  32. - name: Assert language for provisioning nodes
  33. fail:
  34. msg: "{{ fail_language }}"
  35. when: '"en-US" not in language'
  36. - name: Assert provisioning method
  37. assert:
  38. that:
  39. - provision_method == "PXE" or provision_method == "idrac"
  40. success_msg: "{{ success_provision_method }}"
  41. fail_msg: "{{ fail_provision_method }}"
  42. - name: Assert provision_state
  43. assert:
  44. that:
  45. - provision_state == "stateful"
  46. fail_msg: "{{ provision_state_fail_msg }}"
  47. success_msg: "{{ provision_state_success_msg }}"
  48. - name: Assert operating system
  49. assert:
  50. that:
  51. - provision_os == os_supported_centos or
  52. provision_os == os_supported_rocky or
  53. provision_os == os_supported_leap
  54. fail_msg: "{{ provision_os_fail_msg }}"
  55. success_msg: "{{ provision_os_success_msg }}"
  56. - name: Verify the iso_file_path
  57. stat:
  58. path: "{{ iso_file_path }}"
  59. register: result_path_iso_file
  60. - name : Assert iso_file_path location
  61. fail:
  62. msg: "{{ missing_iso_file_path }}"
  63. when: not result_path_iso_file.stat.exists
  64. - name: Validate iso_file_path name
  65. assert:
  66. that:
  67. - result_path_iso_file.stat.exists
  68. - '".iso" in iso_file_path'
  69. - provision_os in iso_file_path | lower
  70. fail_msg: "{{ invalid_iso_file_path }}"
  71. success_msg: "{{ valid_iso_file_path }}"
  72. - name: Warning - waiting for 30 seconds
  73. pause:
  74. seconds: 30
  75. prompt: "{{ dns_empty_warning_msg }}"
  76. when:
  77. - primary_dns | length < 1
  78. - secondary_dns | length < 1
  79. - name: Validate primary_dns is not empty when secondary_dns provided
  80. fail:
  81. msg: "{{ primary_dns_empty_msg }}"
  82. when:
  83. - primary_dns | length < 1
  84. - secondary_dns | length >1
  85. - name: Validate dns inputs
  86. block:
  87. - name: Assert primary_dns when not empty
  88. assert:
  89. that:
  90. - primary_dns | ipv4
  91. success_msg: "{{ primary_dns_success_msg }}"
  92. fail_msg: "{{ primary_dns_fail_msg }}"
  93. - name: Test reachability of primary_dns
  94. command: ping -c3 {{ primary_dns }}
  95. failed_when: false
  96. changed_when: false
  97. register: primary_dns_check
  98. - name: Verify primary_dns is reachable
  99. fail:
  100. msg: "{{ primary_dns_not_reachable_msg }}"
  101. when: ping_search_key in primary_dns_check.stdout
  102. - name: Validate secondary_dns inputs
  103. block:
  104. - name: Assert secondary_dns when not empty
  105. assert:
  106. that:
  107. - secondary_dns | ipv4
  108. - secondary_dns != primary_dns
  109. success_msg: "{{ secondary_dns_success_msg }}"
  110. fail_msg: "{{ secondary_dns_fail_msg }}"
  111. - name: Test reachability of secondary_dns
  112. command: ping -c3 {{ secondary_dns }}
  113. failed_when: false
  114. changed_when: false
  115. register: secondary_dns_check
  116. - name: Verify secondary_dns is reachable
  117. debug:
  118. msg: "{{ secondary_dns_not_reachable_msg }}"
  119. when: ping_search_key in secondary_dns_check.stdout
  120. when: secondary_dns | length > 1
  121. when: primary_dns | length > 1