main.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: omnia.yml runing on host
  51. block:
  52. - name: Passwordless SSH status
  53. debug:
  54. msg: "omnia.yml running on host"
  55. - name: Check whether ansible config file exists
  56. stat:
  57. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  58. register: ansible_conf_exists
  59. - name: Create the directory if it does not exist
  60. file:
  61. path: "{{ ansible_conf_file_path }}"
  62. state: directory
  63. mode: "{{ file_perm }}"
  64. when: not ansible_conf_exists.stat.exists
  65. - name: Create ansible config file if it does not exist
  66. copy:
  67. dest: "{{ ansible_conf_file_path }}/ansible.cfg"
  68. mode: "{{ file_perm }}"
  69. content: |
  70. [defaults]
  71. log_path = /var/log/omnia.log
  72. when: not ansible_conf_exists.stat.exists
  73. - name: Set omnia.log file
  74. replace:
  75. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  76. regexp: '#log_path = /var/log/ansible.log'
  77. replace: 'log_path = /var/log/omnia.log'
  78. when: ansible_conf_exists.stat.exists
  79. when: not control_plane_status