main.yml 2.9 KB

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