main.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: Verify domain name in hostname
  16. block:
  17. - name: Fetch the hostname
  18. command: hostname -s
  19. register: machine_hostname
  20. changed_when: false
  21. - name: Verify the hostname is not blank in hostname
  22. fail:
  23. msg: " {{ hostname_blank_msg }}"
  24. when: machine_hostname.stdout | length < 1
  25. - name: Validate the host name
  26. assert:
  27. that:
  28. - machine_hostname.stdout is regex(("^(([a-z]|[a-z][a-z0-9\-]*[a-z0-9])\.)*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$"))
  29. - machine_hostname.stdout != "localhost"
  30. success_msg: "{{ server_hostname_success }}"
  31. fail_msg: "{{ server_hostname_fail }}"
  32. - name: Fetch the domain name
  33. command: hostname -d
  34. register: domain_name_set
  35. changed_when: false
  36. - name: Verify the domain name is not blank in hostname
  37. fail:
  38. msg: " {{ domain_name_blank_msg }}"
  39. when: domain_name_set.stdout | length < 1
  40. - name: Set fact for the domain name in hostname
  41. set_fact:
  42. ms_domain_name: "{{ domain_name_set.stdout }}"
  43. - name: Validate the domain name set on the host
  44. assert:
  45. that:
  46. - hostvars['127.0.0.1']['domain_name'] == ms_domain_name
  47. success_msg: "{{ server_domain_name_success }}"
  48. fail_msg: "{{ server_domain_name_fail }}"
  49. when:
  50. - hostvars['127.0.0.1']['login_node_required']
  51. - hostvars['127.0.0.1']['ipa_server_ms'] and login_node_group in group_names or
  52. not hostvars['127.0.0.1']['ipa_server_ms']