main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: Perform validations
  16. include_tasks: validations.yml
  17. - name: Fetch omnia_config.yml inputs
  18. include_tasks: fetch_omnia_inputs.yml
  19. - name: Fetch control_plane credentials
  20. include_tasks: fetch_control_plane_credentials.yml
  21. - name: Initialize variables
  22. set_fact:
  23. control_plane_status: false
  24. powervault_status: false
  25. nfs_node_status: false
  26. ansible_collection_used: false
  27. - name: Check AWX instance
  28. command: awx --version
  29. changed_when: false
  30. failed_when: false
  31. register: awx_version_check
  32. - name: Check AWX hostname
  33. command: hostname
  34. changed_when: false
  35. register: awx_hostname
  36. - name: Set control_plane_status
  37. set_fact:
  38. control_plane_status: true
  39. when:
  40. - not awx_version_check.failed
  41. - awx_search_key in awx_hostname.stdout
  42. - name: Install Packages
  43. include_tasks: install_packages.yml
  44. when: not control_plane_status
  45. - name: Set ansible_collection_used to true in awx
  46. set_fact:
  47. ansible_collection_used: true
  48. when: control_plane_status
  49. - name: Set NFS node status
  50. set_fact:
  51. nfs_node_status: true
  52. when:
  53. - control_plane_status
  54. - groups['nfs_node'] | length == 1
  55. - name: Fetch powervault status
  56. include_tasks: fetch_powervault_status.yml
  57. when: nfs_node_status
  58. - name: omnia.yml runing on host
  59. block:
  60. - name: Passwordless SSH status
  61. debug:
  62. msg: "omnia.yml running on host"
  63. - name: Check whether ansible config file exists
  64. stat:
  65. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  66. register: ansible_conf_exists
  67. - name: Create the directory if it does not exist
  68. file:
  69. path: "{{ ansible_conf_file_path }}"
  70. state: directory
  71. mode: "{{ file_perm }}"
  72. when: not ansible_conf_exists.stat.exists
  73. - name: Create ansible config file if it does not exist
  74. copy:
  75. dest: "{{ ansible_conf_file_path }}/ansible.cfg"
  76. mode: "{{ file_perm }}"
  77. content: |
  78. [defaults]
  79. log_path = /var/log/omnia.log
  80. when: not ansible_conf_exists.stat.exists
  81. - name: Set omnia.log file
  82. replace:
  83. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  84. regexp: '#log_path = /var/log/ansible.log'
  85. replace: 'log_path = /var/log/omnia.log'
  86. when: ansible_conf_exists.stat.exists
  87. when: not control_plane_status