pre_requisite.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: Validate skip tags
  16. fail:
  17. msg: "{{ invalid_skip_tag_msg }}"
  18. tags: [ network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
  19. when:
  20. - '"init" in ansible_skip_tags'
  21. - name: Validate run tags
  22. fail:
  23. msg: "{{ invalid_run_tag_msg }}"
  24. when:
  25. - '"init" not in ansible_run_tags'
  26. - '"all" not in ansible_run_tags'
  27. tags: [ init, network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
  28. - name: Mount Path
  29. set_fact:
  30. mount_path: "{{ role_path + '/../../..' }}"
  31. tags: init
  32. - name: Collecting ansible python version
  33. shell:
  34. cmd: ansible --version | grep "python version" | cut -d ' ' -f 6
  35. register: ansible_python_version
  36. changed_when: false
  37. tags: init
  38. - name: Saving management station os
  39. set_fact:
  40. mgmt_os: "{{ ansible_facts['distribution'] | lower }}"
  41. tags: init
  42. - name: Verify the ansible and python versions installed
  43. fail:
  44. msg: "{{ ansible_python_version_status }}"
  45. tags: init
  46. when:
  47. - ansible_python_version.stdout != python_version_leap
  48. - ansible_python_version.stdout != python_version_support
  49. - name: Verify whether ansible configuration file exists
  50. stat:
  51. path: "{{ default_ansible_config_file_path }}"
  52. register: file_exists
  53. tags: init
  54. - name: Set omnia.log file
  55. replace:
  56. path: "{{ default_ansible_config_file_path }}"
  57. regexp: '#log_path = /var/log/ansible.log'
  58. replace: 'log_path = /var/log/omnia.log'
  59. when: file_exists.stat.exists
  60. tags: init
  61. - name: Check OS support
  62. assert:
  63. that:
  64. - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
  65. ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version ) or
  66. ( os_supported_leap in mgmt_os ) and ( ansible_distribution_version >= os_supported_leap_version )
  67. fail_msg: "{{ fail_os_status }}"
  68. success_msg: "{{ success_os_status }}"
  69. register: os_value
  70. tags: init
  71. - block:
  72. - name: Fetch SElinux mode
  73. command: sestatus
  74. register: sestatus_current
  75. changed_when: false
  76. - name: Disable SElinux
  77. replace:
  78. path: /etc/sysconfig/selinux
  79. regexp: 'SELINUX=[a-z]+'
  80. replace: 'SELINUX=disabled'
  81. when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
  82. - name: Status of SElinux
  83. fail:
  84. msg: "{{ selinux_status }}"
  85. when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
  86. register: selinux_value
  87. tags: init
  88. when:
  89. - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
  90. ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version )
  91. - name: State of firewall
  92. service:
  93. name: firewalld
  94. state: started
  95. enabled: yes
  96. tags: init